Another twitter science question. Morena Baccarin (@missmorenab) recently posted:
Flies always find a way INTO your house but never OUT. Ugh! (source)
to which Patrick McAvoy (aka @stamponbunnies) said:
That's because like Mac users, flies don't understand Windows. (source)
Let's put aside the funny for a moment. There is an element of truth here, I'd thought I'd simulate it.
Let's imagine a situation with 100 flies immediately outside the house, randomly hitting windows/doors etc, and no flies inside. Let's say that in each time interval, there is a 3% chance a fly will go from being an outside fly to an inside fly (or vice versa). As all the flies are outside and none inside, this means that a fly is more likely to fly in than out. As the number of flies inside grows, some start to leave. The number of flies stabilise when the number leaving is the same as the number arriving.
In the simple simulation, stability occurs when 50 flies are inside, and 50 outside - i.e. when the number of flies matches inside and out.
This simulation really refers to 'fly density' rather than number - and I've assumed a fly is just as likely to enter as to leave. In practice, flies may be more likely to fly toward light, or toward food etc, so this'd make the stable position different. Swatting will upset the balance for a while, but those flies will be replaced unless you shut the window.
In short, it matters not what the chance of a fly coming through your window is exactly, the number will stabilise - even if you swat them. If there are none inside, some will come in. If there are some inside, they will leave, but others arrive. It's not necessary to assume that the flies came in deliberately and can't leave, only that they are randomly moving. Of course, none of this proves that the flies aren't doing it on purpose....
Note, random fluctuations will happen - but it stabilises (in this simulation) at 50/50. Changing the probability affects how long it takes to stabilise (about 40-50 time periods for 3%), but not the values at which it stabilises.
The only probability which gives no flies inside is 0% - a hermetically sealed house.
Note, with real flies, if the probability of entering the house is low, then night may fall before the stable condition is reached, killing off the flies inside, thus giving fewer flies inside than average fly density would suggest.
Also, in reality it is often true that outsides are bigger than insides. Therefore the outside fly density won't drop in any significant way.
If you want to try this out yourself....
The number of flies entering or leaving was given by:
This was in cell C6, a similar formula was in Column G. Column B was the random number (generated by rand() - not perfect, but good enough. Column A was the number of flies outside, $B$2 was probability of entering. The +0.5 and int were to round to the nearest fly (unless you're very cruel, you don't get half a fly). The *2 is because I wanted a random number of 0.5 to give the probability I entered. With 100 flies and 3% this means between 0 and 6 flies are chosen (averaging on 3).
Note, the details of the table will be different to the graph due to the vagaries of RAND()
|Starting Number of flies outside||100|
|Probability of moving in or out||3%|
|Number outside||Random number between 0 and 1||Random number of flies entering||Number in House||Random number between 0 and 1||Random number of flies leaving|