2 ms·
I checked his comment, I think he's incorrect on the approaches being different. Using my function `foo` that does the iterative approach, we can compare the di
by sobellian 3y ago
I checked his comment, I think he's incorrect on the approaches being different. Using my function `foo` that does the iterative approach, we can compare the distributions and they're fairly identical.
>>> np.mean([foo(100) for _ in range(100000)])
3.258425093913613e-33
>>> np.mean([np.product(np.random.random(100)) for _ in range(100000)])
8.814732867008917e-33
(There's quite a bit of variance on a log scale, so 3 vs 8 is not a huge difference. I re-ran this and got varying numbers with both approaches. But the iterated code is very slow...)
Note that the mean is actually quite a bit closer to 2^-100 even though the vast majority of numbers from either distribution fall below 2^-100. Even so, the mean for both is approximately a factor of 100 less than 2^-100. Suspicious! Although I think we've both burned enough time on this.
- anderskaseorg 3y agoYeah, the problem with your sampling experiment (as your suspicious observation makes it sound like you’ve started to realize) is that this distribution has a very narrow tail to 1 that you won’t hit by accident but nonetheless contributes very significantly to the computation of the mean. You correctly computed that the mean of log(foo(n)) is exactly −n, and the median of foo(n) indeed shrinks like e^−n (more specifically like e^(1/3 − n), I think), but the mean of foo(n) is exactly 2^−n.
- tbalsam 3y agoIf this were stackoverflow, I'd mark this as an answer. Also answers my question up above a bit as well, just from a different approach. Many thanks for clarifying here and elsewhere! :) HN is a lovely, curious, and interesting place.