News for hackers. Stuff that matters.
Re:How many flies are in my apartment? by m12k on Friday June 18, 2021 @07:54AM (#27549426)
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.
Re:How many flies are in my apartment? by Aeolun on Friday June 18, 2021 @10:24AM (#27550638)
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.
Re:How many flies are in my apartment? by m12k on Friday June 18, 2021 @10:43AM (#27550894)
My condolences, that doesn't sound very nice. Unless you're a frog, in which case, congratulations!
Re:How many flies are in my apartment? by vagrantJin on Friday June 18, 2021 @12:14PM (#27551880)
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.

Re:How many flies are in my apartment? by thaumasiotes on Friday June 18, 2021 @11:03AM (#27551104)
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.)

Re:How many flies are in my apartment? by thaumasiotes on Friday June 18, 2021 @04:04PM (#27554371)
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.

Re:How many flies are in my apartment? by paul_manias on Friday June 18, 2021 @12:24PM (#27551992)
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.

Re:How many flies are in my apartment? by grahamburger on Friday June 18, 2021 @01:03PM (#27552457)
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.

Re:How many flies are in my apartment? by layoutIfNeeded on Friday June 18, 2021 @01:14PM (#27552573)
That’s animal abuse.
Re:How many flies are in my apartment? by grahamburger on Friday June 18, 2021 @01:46PM (#27552908)
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.
Re:How many flies are in my apartment? by 411111111111111 on Friday June 18, 2021 @03:25PM (#27553922)
*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

Re:How many flies are in my apartment? by thaumasiotes on Friday June 18, 2021 @03:55PM (#27554255)
> 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.

Re:How many flies are in my apartment? by 411111111111111 on Saturday June 19, 2021 @01:32AM (#27558043)
Not the big ones. The first slap stuns them at best, sometimes not even that.
Re:How many flies are in my apartment? by scrumbledober on Friday June 18, 2021 @12:28PM (#27552045)
This was far more engaging of a story than it deserves to be
Re:How many flies are in my apartment? by gnulinux on Friday June 18, 2021 @01:34PM (#27552775)
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!
Re:How many flies are in my apartment? by nyokodo on Friday June 18, 2021 @03:36PM (#27554043)
> I wouldn't want bugs reproducing in my house, that sounds like a slippery slope!

Don’t Google dust mites.

Re:How many flies are in my apartment? by a11r on Friday June 18, 2021 @06:13PM (#27555570)
Or Face Mites.
Re:How many flies are in my apartment? by Andrew_nenakhov on Friday June 18, 2021 @02:28PM (#27553344)
I admire your perception. I'm personally unable to distinguish different fly specimens, they all look the same to me.
Re:How many flies are in my apartment? by paul_manias on Friday June 18, 2021 @04:36PM (#27554731)
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.
Re:How many flies are in my apartment? by tailspin2019 on Friday June 18, 2021 @08:16PM (#27556551)
> 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.

Re:How many flies are in my apartment? by mkreis on Friday June 18, 2021 @08:15AM (#27549529)
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...
Re:How many flies are in my apartment? by dotancohen on Friday June 18, 2021 @10:42AM (#27550884)
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...

Re:How many flies are in my apartment? by ajnin on Friday June 18, 2021 @03:53PM (#27554234)
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.
Re:How many flies are in my apartment? by lostcolony on Friday June 18, 2021 @04:25PM (#27554596)
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.

Re:How many flies are in my apartment? by saalweachter on Friday June 18, 2021 @04:39PM (#27554772)
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?

Re:How many flies are in my apartment? by lostcolony on Friday June 18, 2021 @05:10PM (#27555088)
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).

Re:How many flies are in my apartment? by thearn4 on Friday June 18, 2021 @09:01AM (#27549830)
Great read!

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

Re:How many flies are in my apartment? by bena on Friday June 18, 2021 @10:04AM (#27550439)
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.

Re:How many flies are in my apartment? by bombcar on Friday June 18, 2021 @11:20AM (#27551282)
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.
Re:How many flies are in my apartment? by pelasaco on Friday June 18, 2021 @08:23AM (#27549577)
Thank you! Great read, indeed!
Re:How many flies are in my apartment? by dilawar on Friday June 18, 2021 @12:39PM (#27552189)
paywalled for me.
Re:How many flies are in my apartment? by ramanan on Friday June 18, 2021 @08:23AM (#27549578)
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.

Re:How many flies are in my apartment? by MereInterest on Friday June 18, 2021 @08:33AM (#27549636)
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.
Re:How many flies are in my apartment? by ramanan on Friday June 18, 2021 @08:37AM (#27549663)
True. I’m no expert in this area, but there are a lot more factors too - including territorial range and even different camera locations.
Re:How many flies are in my apartment? by rozab on Friday June 18, 2021 @08:16AM (#27549535)
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.
Re:How many flies are in my apartment? by m12k on Friday June 18, 2021 @08:32AM (#27549635)
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.
Re:How many flies are in my apartment? by marcosdumay on Friday June 18, 2021 @02:23PM (#27553279)
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.
Re:How many flies are in my apartment? by Woberto on Friday June 18, 2021 @10:24AM (#27550633)
Unless the predator can see in the UV spectrum, like bats
Re:How many flies are in my apartment? by jmiserez on Friday June 18, 2021 @09:33AM (#27550094)
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.
Re:How many flies are in my apartment? by mjaniczek on Friday June 18, 2021 @12:10PM (#27551841)
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?

Re:How many flies are in my apartment? by m12k on Friday June 18, 2021 @12:24PM (#27551993)
You can read more about the technique here: https://en.wikipedia.org/wiki/Mark_and_recapture
Re:How many flies are in my apartment? by esaym on Friday June 18, 2021 @03:20PM (#27553863)
But how do you catch flies!?!?!
Re:How many flies are in my apartment? by JoBrad on Friday June 18, 2021 @08:23PM (#27556596)
Probably using a net and some sort of mild tranquilizer.
Re:How many flies are in my apartment? by OnlyMortal on Friday June 18, 2021 @07:59AM (#27549452)
If they’re randomly distributed, that makes sense.