Post Reply 
An unexpected result involving sums of random numbers
03-04-2023, 02:29 PM
Post: #19
RE: An unexpected result involving sums of random numbers
(03-02-2023 02:06 PM)Albert Chan Wrote:  Last random number, on average = 0.5
Balance (before adding last random number), on average, between 0.5 to 1.0

1.0 < E*0.5 < 1.5      → 2.0 < E < 3.0

I was wrong about last random number average = 0.5
Balance likely contains many small numbers. Last random thus pushed higher (on average).

lua> N = 1e7 -- simulations
lua> S, R, E = 0, 0, 0
lua> for i = 1, N do
:            s = 0; repeat r=random(); s=s+r; E=E+1 until s >= 1
:            S, R = S+s, R+r
:      end

lua> S, R, E = S/N, R/N, E/N
lua> B = S-R
lua> B, R, S
0.7182663624489083      0.6408642227941028      1.3591305852430111

lua> e = exp(1) -- simulation suggested (B+R = S) values, for huge n
lua> e-2, 2-e/2, e/2
0.7182818284590451      0.6408590857704775      1.3591409142295225

We expected E*0.5 ≈ S. Here, expected counts estimated with 2S is better than E.

lua> E, 2*S
2.7186766      2.7182611704860222
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: An unexpected result involving sums of random numbers - Albert Chan - 03-04-2023 02:29 PM



User(s) browsing this thread: 6 Guest(s)