Hacker News new | past | comments | ask | show | jobs | submit login
How many flies are in my apartment? (saml98.github.io)
228 points by maverickleopard on June 18, 2021 | hide | past | favorite | 152 comments



In my statistics class we were taught a technique for estimating the number of flies in a barn. You capture a fixed size sample of flies, e.g. 100, and give them each a little white dot on the back, then release them all back in the barn. Leave them to mingle for a while, then capture another fixed number of flies, e.g. 100. If 5 of them have a white dot on them, then you estimate that the 100 flies you captured originally and marked make up 5% of the total population, meaning your estimate of the total population must be 2000 flies.


I found two flies in my house, marked them, then later found two more flies without marks. I think this means the population of flies in my house is infinite.


My condolences, that doesn't sound very nice. Unless you're a frog, in which case, congratulations!


Dear m12k,

I have a valid reason to outlaw humour.

Because of you comment 3 things have happened.

1) I snorted, causing my hot tea to use my nostrils as an emergency exit.

2) My nose became a tea tap.

3) My screen and keyboard, bless them, are covered with tea. My shame in cleaning it up is indescribable.

Bravo.


You want to consider, based on a distribution of potential fly populations, what the odds are that sampling two of them will fail to capture two specific ones. For example, you can state with certainty that the population is above 3.

Closely related (though not quite the identical problem): https://www.johndcook.com/blog/2010/03/30/statistical-rule-o...

Applying that directly, we would estimate that the odds of a fly in your house being marked are less than 150%, which tells us that you should be taking larger samples.

(With only two marked flies, this estimate will always be less informative than the fact that you sampled n flies -- it will tell you that the population is probably greater than 2/3 of n, while the sampling procedure tells you that the population is necessarily at least n+2. But as you mark more flies, the estimate will be more informative.)


Mostly because I thought it was fun, a worked example where you mark 100 different flies and then catch 100 unmarked flies (releasing each fly individually immediately after catching it; maybe you caught the same fly 100 times):

By the rule of three, we estimate the probability that a fly in your house is marked at p < 3/100.

We can also model the probability that a fly in your house is marked as 100/n, where n is the number of flies in your house.

Then 100/n < 3/100 and n > 100*100/3 = 3,333. There are probably more than 3333 flies in your house.


This reminds me of the time I found two flies in my house despite the windows being closed. I vacuumed them up (more fun that way) and the next day there were two identical looking flies in the house. Did they get out of the vacuum cleaner? I vacuumed them up again.

The next day, same story. The flies were now appearing throughout the day. They all looked the same. Where the hell were they coming from? The windows were still closed. I kept vacuuming.

Eventually things were starting to get very irritating. I hunted for an entry point for days without finding anything and the flies just kept on appearing. I was pretty good at vacuuming flies by this point.

By day six I spotted a group of them hanging out near my Kentia palm. Aha! A fly had laid eggs in the soil of the plant. I had no idea that it was a suitable food source for larvae. Needless to say I quickly filled it with gravel and I guess that's the story of how I became a qualified Fly Detective.


Another fun thing you can do with flies, and also bees and wasps, apart from vacuuming them up, is put them on a leash. But first you have to freeze them.

Catch one in a cup or plastic bag and stick it in the freezer for about 10 minutes. When you take it out it will look dead, but it's not (unless you leave it in too long.) Being careful not to rip it's wings off, tie a small string or fishing line to one of it's legs.

In a few minutes it will thaw and start to walk around, and then start to fly. You can now walk it around the park like you were carrying a balloon.


That’s animal abuse.


Where would you say it falls on the spectrum of animal abuse in relation to going fishing, fly swatting, and walking the dog? Those are all activities I'm personally ok with.


*insect abuse

I think repeatidly slapping them with a pretty soft plastic attraption until they stop moving is even harsher though.

Or slapping them outta the air, trying to electrocute them but having too little power on the shitty device so only their wings get burned.

Or vacuuming them up

Or flushing them down the drain.

Honestly, whatever people usually do to them it's way way crueller


> I think repeatedly slapping them with a pretty soft plastic contraption until they stop moving is even harsher

It's soft to you, not to the fly. You don't slap a fly "until it stops moving". When you swat a fly, it explodes.


Not the big ones. The first slap stuns them at best, sometimes not even that.


This was far more engaging of a story than it deserves to be


That's scary. I used to be a hardcore insectaphobe, but I got over it over the last couple years. Now I don't care that much when I see insects in my house. But it is within reason! I wouldn't want bugs reproducing in my house, that sounds like a slippery slope!


> I wouldn't want bugs reproducing in my house, that sounds like a slippery slope!

Don’t Google dust mites.


Or Face Mites.


I admire your perception. I'm personally unable to distinguish different fly specimens, they all look the same to me.


It's only the size and age of them that makes one fly distinguishable from another. When they're all being born at the same time there's absolutely nothing that makes them distinct, and that's your clue that eggs have been laid somewhere in the vicinity.


> It's only the size and age of them that makes one fly distinguishable from another.

Because of their rarity, I find that the ones that wear tiny top hats are easily distinguishable too.


Reminds me of how the Allies estimated the production capacity of German tanks during WW2: https://medium.com/dataseries/how-data-science-gave-the-alli...


If you're interested, I referenced this and used the technique to estimate the quantity of STS SRBs recently:

https://space.stackexchange.com/questions/9261/how-many-soli...

Oh, no.... The date on that post is 2015... "recently"... I'm old...


My intuitive answer to that problem was to say that if we assume the captured serial numbers are randomly distributed, and the numbering starts at 1, then they will have the same average as all the numbers, so the estimate should be the average of captured serial numbers times 2. Which gives a result close to the formula used in this article, but not the same. I'm not sure where is the flaw.


If there are 100 tanks, and you get 1, 2, 5, and 99, your method would give 54 tanks ((1 + 2 + 5 + 99)/4 * 2), which is obviously wrong.

Your error is in stating "if we assume the captured serial numbers are randomly distributed" - you're assuming they're -uniformly- distributed. Randomly distributed != uniformly distributed.

Their method would give you 125 as a guess. It's including the known info (i.e., adding "m") to take into account the fact that they're not necessarily evenly distributed.

On that note, if you continued to get tanks at low numbers (3, 4, 6, etc), averaging gets -less- accurate, because that 99 becomes more and more of an outlier. Their method gets MORE accurate, again, because they're taking advantage of all data that is known (we know it goes at least to 99), and averaging doesn't. The new low numbers we've added mean that there are less likely to be many tanks, and the formula in the link takes that into account with m/k.

Both methods will be accurate if you have 100% of the data, but taking twice the average ignores known data, so the sparser the data the less likely it is to be correct.


Hmmm, on the other hand, suppose you first find a tank with the serial number 1234.

Then the next 50 tanks you find are all from the range [1, 100].

Is it more reasonable to assume that there are around 1258 tanks, or that there are probably closer to 100 tanks, and that first one with the very large serial number was not a sequentially numbered tank?


Certainly!

But, from the article's initial proposition - "You do know that the Germans have a sequential numbering system (1, 2, …, n)" and in giving historical context "On investigation, it became clear that the serial numbers were sequential, without gaps."

So, yes, without that being a prior, of course it's more likely that that outlier is a strange one off, and you'd do better to exclude it from your data set (and/or continue to investigate, because it's NOT at all clear that the serial numbers are sequential yet).

But, that context and ordering matters. Assume just the opposite series of events - you started by finding 50 tanks with serial numbers [1, 100]. And then three or four months go by you didn't get any tank serials sent to you. And then you get 1234. 1258 tanks seems really reasonable at that point (and, in fact, would fit the reality; the Germans were producing ~256 tanks per month per the article).


Great read!

In comparison, I have to wonder why the "intelligence estimates" were so bad/severe over estimates.


My intuition says counter-intelligence. The Allies were using intercepted communications, visual confirmation, captured sources, etc.

You can send fake reports if you think the other side is listening. You can move or mock material if you think the other side is watching. You can feed false information if you are captured.


And this is why you may be better off solving the “serial number problem” not by going to entirely random ones but instead change to one that implies false data that you want the Enemy to find.


Thank you! Great read, indeed!


paywalled for me.


This catch and release pattern is quite common in many wildlife surveys.

For example, when estimating tiger populations, instead of painting a white dot, rangers set up camera traps to take photos. Then they can use stripe patterns as a signature for subsequent re-appearances. Quite an interesting intersection for image AI with statistical counting methods.


Are there adjustments that need to be made for non-random sampling in that case? I'd imagine that with any territorial animal, a stationary camera is most likely to see the same animal multiple times.


True. I’m no expert in this area, but there are a lot more factors too - including territorial range and even different camera locations.


Fun idea, but presumably there is a big bias in that some flies will be easier to catch for various reasons. I suppose lots of population studies on birds, cetaceans or whatever have this bias, since you can't just slap a quadrat down and catch everything. In fact with these more advanced animals, perhaps they're harder to observe a second time since they've learned to be wary of humans.


Right, if you're measuring long enough that predators eating some of the flies could be an issue, then you'd want to mark them with something only visible under a blacklight, or similarly "neutral", so it doesn't introduce a bias.


If predators or age (or moving out or into the measured area) are a factor, they are already biased and keeping your method neutral will still give you very wrong results.


Unless the predator can see in the UV spectrum, like bats


My first ever job (in high school) was manually counting mosquito larvae in water samples for our local department of agriculture. IIRC the aforementioned technique doesn't really work for that, instead they collected samples regularly for several months at the same spots each year and used that for their forecasts.


I wonder how does that work. Why can you use the 5 flies you found to divide the total sample size?

It's kind of giving you an invariant number: * 100 flies -> 5 flies (5%), 100 / 0,05 = 2000 * 80 flies -> 4 flies (5%), 80 / 0,04 (not 0,05) = 2000

But if you used the percent instead (which seems to be what you hinted at) then the results vary: * 100 flies -> 5 flies (5%), 100 / 0,05 = 2000 * 80 flies -> 4 flies (5%), 80 / 0,05 = 1600

What's the principle, does it have a name I could read more about on Mathworld / Wiki?


You can read more about the technique here: https://en.wikipedia.org/wiki/Mark_and_recapture


But how do you catch flies!?!?!


Probably using a net and some sort of mild tranquilizer.


If they’re randomly distributed, that makes sense.


All these models ignore how insects actually zero in on a smell. For a fly outside, the source of the smell is the gap in the window. What looks like random direction changes is actually a search pattern for that source.


Very good point -- and that's why they find their way inside so easily, but look really dumb trying to find their way out.

Same principle behind a DIY fruit fly trap (glass of juice with a plastic cover with a few holes poked in it).


Then why only two?


You are right. Even though it is probably a great exercise to improve your skills as data scientists, I'm afraid that without understanding how the insects actually "work/think", it is nothing more than garbage in, garbage out (GIGO).


I don't know how intentional it was but that's a great roast on data scientists.


Slightly related: Anemotaxis https://www.youtube.com/watch?v=hIqmIQbQkW8


Thanks, that was actually the screensaver I was thinking of when I wrote my comment :-)

But I don't actually know whether flies do use this pattern.


There is presumably also a falling-off of the signal with distance. Flies may have a good sense of smell and all, but it's not infinitely good. Which is too bad, because if they did, then all the flies in NYC (or I suppose maybe the world) would all be in one big clump near the best (to a fly) smelling object. Although I guess if you were that object, then it would be not as good.


Sure, the inverse square law applies to smells as well.


> All these models ignore how insects actually zero in on a smell.

It seems to me that the author is not ignoring that:

> While the flies now obey the laws of aviation, there's still something that seems missing. Normally, flies want to get indoors. They need to get indoors. So to simulate this, I added an attractor (maybe a rotting piece of fruit) at a position A indoors to lure the flies.


The model where the fly knows where the source of the smell is located the weird outcome of the flies targeting the pane in the middle instead of the sides where the smell escapes.



Thanks, that was an interesting read on the topic!


From experience: about 5x as many as you think

Story: I was living in a large flatshare that was plagued by flies from nearby horse stables. We were organizing a decent sized party (maybe 40 guests). In the afternoon, we had 15ish items of food that needed to be stored for a few hours until guests arrived. At first we considered covering all the food (creating work and waste of aluminum or plastic foil), then I had the idea to kill all the flies in that room and close the door. We saw about four flies. In the end we killed about 20 before we declared the situation good enough. I don't recall if there was a last fly that we eventually killed, or that we eventually gave up on killing. It took half an hour or so.


This reminds me of the flocking boids algorithm by Craig Reynolds [0] which is based on three principles:

  + separation: steer to avoid crowding local flockmates
  + alignment: steer towards the average heading of local flockmates
  + cohesion: steer to move towards the average position (center of mass) of local flockmates
The algorithm was used to animate the bat swarms in Batman Returns (1992) [1].

I love this algorithm, it's easy to develop and experiment with and the results feel beautiful & natural.

  [0]: https://www.red3d.com/cwr/boids/
  [1]: https://en.wikipedia.org/wiki/Boids


Next step is to set up a grid of ESP32s with MEMS microphones and a FFT routine, stream that data to a server and apply some neural network to get to know the real amount of flies by tracking them individually. Then compare this to the model, and keep improving it until it fits.


I want a mosquito-killing turret [1] that you could put in your bedroom and sleep in peace.

Turns out one exists [2] (in theory—no commercial product a decade later), but the one I was thinking of would use microphones rather than cameras [3] to detect the bloody suckers. Thing is, I can't find any prior research or even hints that people have considered this approach. (The closest I can find is an app [4] that detects a mosquito from ≤10cm away.) Here are some of my guesses for why it's not been done:

    A. Maybe it's too difficult to distinguish mosquito buzz/whine from background noise, even when filtering in only known mosquito frequencies (~400Hz [5]).
    B. Maybe it's too slow to sweep a room with a directional mic that's focused enough to detect mosquito sounds? (Say the turret in one ceiling corner of a 12x12x8ft room.)
    C. Maybe directional mics don't work well for all sound in their cone and so need to be able to "focus" at different distances (by dynamically changing the parabolic dish's shape), thereby increasing the room sweep time?
    D. Maybe the parabolic dish needs to be so big that it just looks ridiculous?
    E. Maybe all of this is possible but the type of microphone is so expensive that it's worth pursuing commercially?
I'm curious what you all think about this. It'd be an interesting thing to try making—who hasn't wanted to make a death ray while simultaneously furthering the fight against humanity's deadliest enemy? [6]

See also this research paper: Detecting Insect Flight Sounds in the Field: Implications for Acoustical Counting of Mosquitoes [7] (I'm pretty sure this is not directional—they hung an attractant 15cm from the mic and I don't see any dish.)

[1]: https://www.youtube.com/watch?v=BKm8FolQ7jw

[2]: https://www.ted.com/talks/nathan_myhrvold_could_this_laser_z...

[3]: I don't think cameras are well-suited to detecting something so small. The "photonic fence" from the TED talk only kinda works by adding a white background behind the bugs so it's really easy for the camera to detect them—not that practical in a normal room.

[4]: https://www.theguardian.com/science/2018/mar/29/mosquito-ear...

[5]: https://www.youtube.com/watch?v=Rcm3rPz_Q94&t=127

[6]: https://mysteriousuniverse.org/2014/08/why-mosquitos-are-hum...

[7]: https://pdfs.semanticscholar.org/a0bf/4fcd478b6214759046a739...


My acoustically-minded friend had the following to say:

> Off the top of my head, I'm guessing the problem has mostly to do with background noise, and it only working in moderately quiet environments.

> As for locating the source of a sound, there's plenty of research that's been done about that. A directional mic doing sweeps is probably not your best bet, as it would be slow and difficult to cover three dimensions. I would think using an array of microphones and using volume and time delay to identify location would be much easier. Setting them up in a triangular pyramid would, I think, allow you to triangulate a sound's position in three dimensions. The problem with this two-fold: it's still not super precise, and the mosquito's whine is a steady sound, not an impulse where it's easy to identify time-delay between locations. You'd probably need to have an incredibly high sample rate to identify strong enough variations in the sound of a mosquito to effectively use time-delay, or place them far enough apart to rely on relative volume. Maybe a set of microphones you can set up around a room, rather than a single location would work better.

> I think this could be solvable by having the laser aim towards the sound and do a rapid sweep of the area, rather than a precision strike. You could also potentially have the device hit targets that will confirm they are being hit when you are setting it up so it can calibrate to the environment that it's in under regular conditions.

> Another thing to consider is that you would also probably need temperature and humidity detection, as both of those can affect how sound travels, even over short distances.

I then did more research on the killing part of this—the laser. The product I linked above uses two lasers—a low-power one to pinpoint the target and to "listen" for its exact frequency to rule out benign insects and a high-power one to give it instant heatstroke or burn off its wings. But with computer-aimed lasers (even non-burning visible green lasers), accidental blindness is a real concern especially indoors where the beam can unexpectedly reflect off glass or other shiny things. So maybe a narrow, powerful non-coherent flashlight could act as a spotlight and that'd be good enough for a human to still kill it.


All this work, to suggest a fly spotlight device is hysterical. That would be marginally helpful, and maximally frustrating. I lend the project my full support were it to ever materialize.

Thank you for this analysis.


A tip if you have an annoying fly in your house that's hard to swat. Turn off all the lights except the bathroom. In a few minutes it'll fly in. Close the door and it's mano-a-mano.


Works well with mosquitoes too. I just let them do whatever they want in the bathroom once the door is closed.

However I would admit that switching lights on at 3AM and deliberately opening all the doors for the light to be seen is not something my family appreciate. But, at least, I’m their hero.


Also works with a computer display in a dark room. Until you hit the display going mano-a-mano.


In the NetLogo Models Library there are quite a few similar models already, "Moths", "Ants", "Gaslab Maxwells Demon", and more variations (adaptive/nonadaptive, single/flocking etc)

http://ccl.northwestern.edu/netlogo/docs/


If you’re already interested in flies, check out how they behave in nature. They can be quite territorial about their leaf or stick and fights between these agile little beasts are fascinating to watch (extremely quickly orbiting each other).


Well, there was at least one startup that addressed the issue of flies/mosquitoes indoors. Bzigo. https://bzigo.com/

It's a machine vision system that tracks mosquitoes and aims a laser pointer on them (so you can swat them). Don't know if this company still exists. It was/is an Israeli start-up and apparently not an April Fool's day joke.

It seems to me the best solution is to use screens, but that is not as sexy as machine vision.


> It seems to me the best solution is to use screens, but that is not as sexy as machine vision.

There are lots of windows that don’t work with screens. For example some windows are pushed out as opposed to up, and the latching mechanism would conflict with the screen.


Is it better to leave windows open so flies can escape or closed so they never come in?


If your windows open outwards, windows open, no contest.

If however they open inwards like mine, open sounds good in theory... but you may end up more frustrated at idiotic flies buzztapping against the interior side of the glass time and time again, rather than flying around it and getting the hell out. Might as well keep the windows closed and accept the flies are here to stay rather than living in false hope while new ones keep buzzing in.


Window closed means no flies could ever come in, whereas with an open window it's a possibility. So purely from a statistical point of view...

I've never noticed the number of insects reducing from open orifices, only increase, presumably until it's the same number per m³ as outside (or higher if you have food out, perhaps). I won't rule out that there might exist configurations where flies are more likely to fly out of than in to, but aside from conical shapes designed to do that (i.e. not regular windows), has anyone ever noticed that opening a window reduced the number of insects inside?


Open windows for air, but have a finely masked net covering the opening so insects don’t get in.


This is the norm in the south asian country I come from.

But ever since I moved to the EU, there have been no nets, then again there are noticeably fewer flies here too.


Differences in regional naming and screen types are causing confusion in nearby comments.

A screen door can be a secondary exterior rigid door with metal mesh panels[1], or a hanging fabric mesh door[2]. A window screen can be a metal mesh, in a rigid metal frame, tightly integrated with a window[3], or a flexible add-on[4].

The polyester/fiberglass/etc fabric meshes can be more opaque than the metal ones.

[1] https://upload.wikimedia.org/wikipedia/commons/2/22/Screen_d... https://www.lowes.com/search?searchTerm=screen+door [2] https://www.alibaba.com/trade/search?fsb=y&IndexArea=product... [3] https://www.youtube.com/watch?v=oEdK5h6smTU [4] https://www.alibaba.com/trade/search?fsb=y&IndexArea=product...


In Kazakhstan we're using nets because of mosquitos. Flies are not a real issue, they're a nuisance, but not a big deal. Mosquitos on the other hand are real night-killers. Few of them might keep me awake until sunset with their buzzing. Of course preventing flies is a good side effect.

In South Asia, I could imagine that mosquitos are more dangerous because of diseases they transmit.


Grew up near a forested area by the Danube river.. everyone and their dog had nets on their windows else the mosquitoes would turn your life into a nightmare.


It's becoming increasingly common where I live (Poland). We've installed nets in our last apartment, and the current one came with them already in place.

There may not be that many flies in the EU as there are in South Asia, but there's enough of them to be annoying. Then there are mosquitoes, moths, wasps, bees - and the very bugs I've been installing these nets against - hornets. Before the net, we'd get 3-5 hornet visits per season. Running around the house late at night with an improvised flamethrower got tiring very quickly.


Okay, first of all, tell me more about this flamethrower.

Also, when you say "nets", do you mean "screens", ie on the windows?


> Okay, first of all, tell me more about this flamethrower.

Just a lighter, a spray can, and steady hands. I know you're probably disappointed, but simplest solutions do work best :).

(To be absolutely clear: I only use this against wasps and hornets, and only in situations where there's no safe way of shooing them back out through a window.)

Operation: hold the lighter in front of you, light the flame, spray above it. Aim for sub-second bursts of flame - you don't want anything in the room to heat up. Never let the flame come close to any highly flammable surface (like drapes, or aforementioned mosquito net).

Tactics: against hornets and wasps, I shoot either below it, or at it directly. Shooting below, the rising hot air will confuse the bug, possibly stun it for a moment. Shooting at it, a sub-second burst is enough to burn off is wings, at which point you can finish it off using your favorite percussive maintenance tool.

Equipment considerations:

- I tend to use cheap, widely available flint lighters. I have experimented with gasoline and butane (high-pressure) lighters before, but IIRC, they didn't work well.

- For fuel, I use a deodorant. In the past, I've also used a hair spray - it's a good choice, because it enables a third mode of operation: cold mode. Because hair spray is viscous, hitting a bug with it is likely to clog its breathing apparatus and glue its wings, allowing you to safely apply the killing blow. I found it useful in a tent[0], where you absolutely do not want to play with an open flame of any kind. Anyway, any kind of spray with a flammable mixture will work, but pay attention to the possible combustion products. I do not recommend going for pressurized butane gas directly - it won't combust fully, and you'll be cleaning soot from every solid surface near you (ask me how I know).

I've been thinking about building/3D-printing a mount to operate the flamethrower single-handed, but to be honest, using two hands gives greater control, and the optimal distance between the lighter and the spray can varies with the type of spray can and environmental conditions.

> Also, when you say "nets", do you mean "screens", ie on the windows?

Yes. I buy a box with a fine mesh net, which I cut down to size and attach to the inside of the window using provided mounting strips (adhesive on the window frame size, velcro on the net side). We call this "moskitiera" (mosquito net). For balcony doors, there are variants with the net split in half and held together with magnets - so you can walk through it, and it'll close behind you.

--

[0] - I was once on a two-week camping trip where we were constantly assaulted by swarms of wasps. We didn't know until later that it was because there was a hive under the building near our site. The organizers of that camp actually funded me a supply of hair spray, and designated me as the camp's exterminator. The "cold mode" was useful for cleaning out tents every couple hours. After we left, the owners of the building decided it's too much hassle to clear out the hive, and burned the building down.


takes notes furiously


Dont the windows have screens? In the US pretty much every window has a permanent screen outside the panel for this purpose...just assumed it was the same in europe


Not in south of Europe unless is a mosquito disco location. One of the main purposes of windows is to see out. The more transparent, the better.

Another factor is the light level. If you have a lot of days with rain or low light, like UK or many other places have, nets reduce even more the level of light entering in the house. Lacking of a lot of the dangerous mosquito borne diseases than tropical places have, the cons weight more than the pros. Would be seen as a better deal in California for example, where the extra shadow is welcomed.

And finally there is some inertia provided by cultural factors. For Dutch allowing everybody to see your room by default (don't have anything to hide here) is a cultural post-war thing also.


Idk I've just never even considered losing light because of the screens, it's so little.

Maybe I'm just used to it.

Also it's not only like a cultural thing, I legally had to put screens in every window of my house before it was able to be occupied. Just an anecdote...

It's weird how we never question things like that.


FWIW that applies to a lot of your 'codes'. Obviously we have regulations too, but it's bizarre (from an outsider perspective) how much it comes up in US television, or online, and (and in part it seems due to) the extent of it.

Regarding light - leaving aside however much it blocks light for illumination purposes, what about seeing out? I want to look out of the window, not look at a mesh all but completely obscuring the view.


I have a mesh missing on one of my windows. For over a year after moving into this house I literally couldn't remember which one without looking up close. It's just that unobtrusive.


The mesh material is extremely thin. As long as you're focusing past it, you don't see the mesh itself. Just maybe the color of it, which is why black mesh is a popular color.


They do not, and it's unfathomable why. One of the first things I did after moving to Berlin was put screens on our major windows. My European friends constantly complain about insects coming in (wasps are a big offender in Berlin - and technically you can't kill them) but for some reason never just put up a screen.


Because I don't want some ugly thing strapped to my window?

Because I want to let more light in?

Because things flying in is approximately not a problem anyway?

Seems perfectly fathomable to me.

(I live in London, occasionally a fly will come in and chill out for a bit before sodding off again.. fine? I've never had a wasp inside even. Our mosquitoes will extremely rarely give you anything nasty. Moths that would fly in aren't the fabric-eating kind. Even leaving aside the other issues, there's no reason to, it wouldn't be worth my time or money to buy them/fit them/have them fitted. I've spent longer writing this comment than being irritated by anything flying in through my windows.)


This sounds like a potentially lucrative business opportunity!


They are for sale, for cheap, in every drug store.


The number of presumably Europeans in here citing screens blocking light as a reason for not installing screens makes me think maybe those screens are pretty low quality?


They are low-quality in that they tear pretty easily, you need to replace them every 3-4 years or if a bird/cat goes nuts on them (5 eur or so per sqm, probably there are cheaper brands if you are price-sensitive), but they don't block any more light than screens in the US. Less than some I've had.


> They do not, and it's unfathomable why.

Our current windows pivot in the middle which makes a fixed screen impossible.

(They do have a "pane inside" mode which would let you put a screen on the outside but we're 3 floors up and it would be a bit tricky, not to mention inconvenient when the temperature drops.)


I can see this being an issue, though everyone I know has some variant of the standard "German window" (https://2.bp.blogspot.com/_gv8PbeT2Ktk/TDiZRMA5oGI/AAAAAAAAA...) where they work fine.


Maybe because screens make the appartment darker?


Fortunately, the sun is getting brighter


I mean generally you can't tell from more than 5 feet away so...idk seems like a minor difference


Why can't you kill wasps?


This calls it a 'myth', but really concludes that it's hyperbole arbitrarily calling out wasps; they're technically a protected species and you could be fined but.. almost certainly not going to happen for one or two wasps bothering you at a cafe or whatever?

https://medium.com/@sophanemwise/the-wasp-killing-myth-in-ge...


I had a friend kicked out of a cafe once for killing a wasp because they didn't want to deal with the situation if the Ordnungsamt was walking by or something.

Wasps are the usual example because it's legal to kill flies/mosquitoes and no one wants to kill the other protected insects like bumblebees. The wasps in Berlin are common and pretty aggressive, and have free rein in an awful lot of the chain backeries.


I was at a country cafe in the UK where there were plenty of wasps nearby. They had some 'fake nests' hanging up, as apparently wasps will swarm and kill intruders, so they also don't go near nests that they know are not their own.

If it works or not I don't really know but at least I had a bowl of ice cream and wasn't especially bothered..


Interesting, but are they justified in that fear do you know?

What I mean is, if this is a commonly believed exaggeration then it could just be that in this case the person believing it wasn't the wasp-killer (or would-be-killer) but the cafe owner. Has your friend ever actually been fined for doing it, or did the cafe owner/manager mention having had to deal with it in the past?

Certainly does seem odd that this law would (a) exist; and (b) be intended to stop this sort of behaviour; and (c) actually be enforced!


I doubt anyone has been fined the full value just from killing one wasp from some random fine. It is regularly enforced against people who try to burn down or otherwise remove nests on their property (without engaging a professional to try to remove it safely for both parties).

I would say mainly it's not enforced because b) has been effective - Germans (or Berliners at least) don't kill wasps! If doing so became common, it would probably be enforced more consistently.


When I lived in Europe there were no screens on the windows.

However, there were also pretty much no bugs; we kept the windows and doors open regularly without an issue - if you tried that were I live now in the US you'd have flies inside making a racket and be eaten alive by mosquitoes.


I've pretty much never seen a screen in the UK. I think they might be more common in hotter countries further south.


In California there’s a decent amount of homes without screens. I’ve lived in two apartments that had no screens (one was a fire escape, the other opened outwards and had a latching mechanism that made it impossible to add a screen).


Also less mosquitoes, and the drier air makes airflow somewhat less of a living requirement: iirc screen doors are also ubiquitous in the (humid and hot) US south, much less so in the north.

window and door screens do absolutely exist in europe, but they’re definitely uncommon.


Depends where in the EU. mosquito nets are quite common around the mediterranean, you'll see roller screens on most bedrooms around here


Also the norm in the US. All my windows have screens built in.


Not sure that answered the question properly


it makes the question not exist any more, same thing.


Context. Which place (outdoors or indoors) is more attractive to the flies/insects? Temperature, Humidity, other attracting factors - depending on region and other related params, this may change with time of day etc


Ive left two windows open almost constantly for a month during the summer and the flies were not that bad.


Based on my experience, those flies need to be less like jittery dots, and more like kamikaze pilots, hurtling themselves from one side of the simulation to the other, repeatedly.


Lévy flight foraging hypothesis: https://en.wikipedia.org/wiki/L%C3%A9vy_flight_foraging_hypo...

The scent-tracking mode used here seems to be a sort of variant, in which the long legs are not chosen randomly.

WRT the insect density decreasing as some fly away: in reality, others will arrive at approximately the same rate, keeping the density approximately the same, so it is probaby more realistic to put a box around the simulation, e.g. by reversing the direction of those that have moved away to the point that they would be several time-slices away from entering the window even if they flew back in a straight line.


I tried showing the flies using matplotlib.animation.FuncAnimation in a notebook, animating even 1000 frames is slow and it warns the animation becomes too large. Maybe there's a better way to do it? Preferably in a notebook interface.


pyqtgraph is a nice matplotlib replacement when speed matters, but doesn't work in a notebook


I ended up writing some very rudimentary HTML canvas + javascript drawing code into the notebook and for my purposes it's fast and does the job. Just to note to others, that this is a possibility within a Jupyter notebook.

One obvious benefit is that it can start rendering "live" and continuously and doesn't have to generate the whole animation before starting to show it.


How exactly do you that and can you interop with python?


I just used this in the Jupyter notebook (toldya it was very simple, written today :).

It interoperates with python by being passed data to the draw call.

Usage like: c = Canvas(); c.draw(xs); xs is a numpy array of shape (N, 2), the points to draw on the canvas.

It's not fancy. But it drew animations faster than matplotlib (I ran this for thousands of frames, just to watch the simulation).

    import IPython.display as ipydisplay
    import json
    import numpy as np

    class Canvas:
        def __init__(self, canvas_id=None, width=500, height=500):
            self.display_id = None
            self._canvas_id = canvas_id or ('canvas_' + str(np.random.randint(0, 10000)))
            display(ipydisplay.HTML(f"""

            <canvas id="{self._canvas_id}" width="{width}" height="{height}" style="border:1px solid #d3d3d3;">
            Your browser does not support the HTML5 canvas tag.</canvas>
            """))

        def draw(self, xs, world_size):
            xs_string = json.dumps(xs.tolist())
            obj = ipydisplay.HTML(f"""
            <script>
            var c = document.getElementById("{self._canvas_id}");
            var ctx = c.getContext("2d");
            var xs = {xs_string};
            var size = {world_size};
            ctx.clearRect(0, 0, c.width, c.height);
            var scale = c.width / size;
            for (let i = 0; i < xs.length; i++) {{
                ctx.fillRect(xs[i][0] * scale, c.height - xs[i][1] * scale, 2, 2)
            }}
            </script>
            """)
            if self.display_id:
                ipydisplay.update_display(obj, display_id=self.display_id)
                return self.display_id
            self.display_id = display(obj, display_id=True).display_id


That's awesome. I'm probably gonna start using this instead of matplotlib


Maybe just use ipycanvas instead - it's on PyPI :) It works the same way except it's not a hack. I found it after I posted.

I went through:

- matplotlib animations (super slow, not live)

- writing an image with PIL and updating display (flickers)

- custom html+canvas code

- ipycanvas

I call display() on the canvas and then run the draw update loop on the canvas later in the same cell. That way the canvas is first displayed and then "live" updated.


Oh wow even better. Thanks for enlightening me on this


This sounds like the "how many balls can fit in a bus" interview question, but somehow more entertaining. Possibly because it addresses a real-world situation.


Looking forward to this showing up on my next interview...


Really interesting work. I love the different models of how a fly moves around. This jumped out at me, though:

>If we take a look at the animation now, we can see the flies look slightly more realistic (if not still a bit spazzy)

Is "spazzy" a word that's used in different regional dialects of English as a term to just mean jittery? In most of the places I've lived, it's an offensive word.


I remember thinking that the UK has a much more negative connotation for "spastic" than the US. In the US it's still pejorative but something you could say casually.


"Spazzy" or "spastic" is not especially offensive in the US, although I suppose given our ever-escalating sensitivity it soon will be. It mostly just implies "given to spasms", which I suppose is the origin. More generally, it implies not terribly well-organized in behavior. A person might say it of their own behavior without meaning anything exceptionally bad.


It has been offensive in the US since the 90s. It just gets used anyway anytime there's some "anti-PC" movement, along with "gay" to mean "bad", the r word, sudden spikes in the use of "niggardly", and so on. Like those, its offensiveness does not come from offense taken by the person/thing it is proximately describing.


I've only heard it used as a synonym to "jittery" or hyper-active in my region of the states (mid-west). Good to know it's considered offensive in places, not that I really use the word. I had a colleague in school that had the nickname of "spaz". Mostly it was used ironically because they were super laid back all the time.


https://en.m.wiktionary.org/wiki/spaz

Seems like it is indeed much more offensive in the UK. I've never heard it used to mean "stupid" or "incompetent" in America. Here, it describes someone who might be scatterbrained, unorganized, eccentric, and a bit hyperactive or frenetic, but not necessarily unintelligent - you might describe your professor as "a bit of a spaz" without anyone taking offense, though you probably wouldn't say it to their face.


[flagged]


huh? It was a legit question. I've lived in a lot of places with different dialects of English. Where a term in one place is seen as harmless, but means something completely different in another.

In this case, I've never heard "spazzy" used other than as an offensive term.

Your reaction seems more Reddit than HN, though. So you have that going for you.


A fly is unlikely to fly randomly.

https://en.wikipedia.org/wiki/L%C3%A9vy_flight


I was really confused about where this was going when I started reading as I thought the title sad files, not flies...


Same here. Turns out to be a staggering number of files actually, much larger than the number of flies.



For some reason this reminds me of the Damien Hirst art work A Thousand Years[1].

Next step for me would be to turn the attractor into an Insectecuter.

1. https://damienhirst.com/a-thousand-years


There are two hanging around and I've named them after people I hate. I keep the windows open in the hope they'll just fly off.


This would be an interesting thing to prove with OpenCV


Flies are small... you'd need a lot of light, multiple angles and good cameras/lenses to decently illuminate the flies, which has the problem that all the light will only attract more flies.


Is this really true? I mean we've had tech like Hawk-Eye[0] for a couple of decades now.

Surely we cameras good enough for fly tracking technology in 2021?

[0] https://en.wikipedia.org/wiki/Hawk-Eye


That camera system tracks a single, largish object in perfect lighting.

I think the biggest problem with insect tracking is focus: They are so small that they can only be recognized if they are perfectly in focus, so you probably can't track them in 3D volumes.

Maybe you could track them with clever lighting tricks. Eg. illuminate room with very bright light coming from the side, with a black wall, so that mosquitos show up as bright spots in the video.


I think it would be fine if you tracked only the flies that entered or exited through the small hole in the wall, ie not tracking the whole room just a tiny corridor.

So yes, you know the delta-fly(er) but not the number of flies.


And if there were a small door over the hole, that opened only to allow fast moving flies to go through it from one direction and slow moving flies to go through it in the other...


> The perfect question for a Sunday afternoon when you have no friends

I have one, we both read your post and we just befriended you without authorization


Maxwell's kinetic theory of flies?


Yes, the path each one takes can very accurately be called a "random fly".


go to the store and buy a removable screen dude. i got one in chinatown for like 5 bucks.


very cool

it would be fun to add static attractors -ie fruit to see how it biases the trajectories


Are you trolling or did you not read far enough?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: