Re:Ask HN: How many times will this loop run on average?
by aalhour on Sunday December 31, 2023 @03:36PM
(#38827333)
Not sure that adds up, I translated the right side of the equality into a Python statement and it returns a number I am not sure how to interpret:
Both the median and mean are around 12 for 10K runs of the loop.
[ Parent
| on HN ]
Re:Ask HN: How many times will this loop run on average?
by hardlianotion on Sunday December 31, 2023 @03:47PM
(#38827401)
I edited my response with an apology! Thanks for checking!
Re:Ask HN: How many times will this loop run on average?
by aalhour on Sunday December 31, 2023 @03:57PM
(#38827454)
No worries, I think your solution coverges with @Someone's above, if I am not mistaken. You're multiplying the probabilities for all values of j up to i for all values of i.
Re:Ask HN: How many times will this loop run on average?
by hardlianotion on Sunday December 31, 2023 @04:06PM
(#38827524)
Yes I am and yes I think it does