## [Question] Random Numbers & Expected Stddev

For the discussion of math. Duh.

Moderators: gmalivuk, Moderators General, Prelates

brainfsck
Posts: 9
Joined: Sun Apr 05, 2009 12:05 am UTC

### [Question] Random Numbers & Expected Stddev

Hi,

I was wondering if anyone could help me with this (non-homework) question that I've been wondering about:

If you sum x integers in the interval [-y, y] z times, what is the expected standard deviation of the results you obtain?

For example, one trial would look like (Mathematica code):

Code: Select all

(* numSum=x, interval=y, tries=z *)
onTrial[numSum_, interval_, tries_] :=
StandardDeviation@
Table[ Total@RandomInteger[{-interval, interval}, numSum], {q, 1,
tries}];

Through brute force simulations, I arrived at the solution $\sigma \approx 0.579 \sqrt{x}y$
However, I'm not positive that's right and it certainly isn't mathematically exact.

Thanks,

GreedyAlgorithm
Posts: 286
Joined: Tue Aug 22, 2006 10:35 pm UTC
Contact:

### Re: [Question] Random Numbers & Expected Stddev

A single number from U[-y,y] has mean 0 and stddev sqrt((y^2 + y) / 3). Summing x of these gives approximately a normal random variable with stddev sqrt(x) times the individual stddevs. The expected standard deviation should be pretty close to this, and it almost agrees with your result:

sqrt(1/3) * sqrt(x) * sqrt(y^2 + y) ~= 0.577 sqrt(x) y sqrt(1 + 1/y) ~= 0.577 sqrt(x) (y + 1/2)

So if you were using large x, and your estimate was using a single y, I predict your y was between 115 and 192. Which I guess means 128 or 150.
GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

brainfsck
Posts: 9
Joined: Sun Apr 05, 2009 12:05 am UTC

### Re: [Question] Random Numbers & Expected Stddev

GreedyAlgorithm wrote:A single number from U[-y,y] has mean 0 and stddev sqrt((y^2 + y) / 3). Summing x of these gives approximately a normal random variable with stddev sqrt(x) times the individual stddevs. The expected standard deviation should be pretty close to this, and it almost agrees with your result:

sqrt(1/3) * sqrt(x) * sqrt(y^2 + y) ~= 0.577 sqrt(x) y sqrt(1 + 1/y) ~= 0.577 sqrt(x) (y + 1/2)

So if you were using large x, and your estimate was using a single y, I predict your y was between 115 and 192. Which I guess means 128 or 150.

Wow you made that seem quite easy. Thank you very much for your time.

EDIT: Actually I have another question:

Why does "a single number from U[-y,y] have mean 0 and stddev sqrt((y^2 + y) / 3)"? From this formula, I get that the stddev should be [imath]\sqrt{\frac{1}{2y}\sum _{i=-y}^y i^2} = \frac{\sqrt{(1+y) (1+2 y)}}{\sqrt{6}}[/imath].

GreedyAlgorithm
Posts: 286
Joined: Tue Aug 22, 2006 10:35 pm UTC
Contact:

### Re: [Question] Random Numbers & Expected Stddev

brainfsck wrote:Why does "a single number from U[-y,y] have mean 0 and stddev sqrt((y^2 + y) / 3)"? From this formula, I get that the stddev should be [imath]\sqrt{\frac{1}{2y}\sum _{i=-y}^y i^2} = \frac{\sqrt{(1+y) (1+2 y)}}{\sqrt{6}}[/imath].

Let's see... first off, that should be 1/(2y+1) instead of 1/2y, since in [-y,y] there are 2y+1 integers. Second, your summation should be [imath]\sum _{i=-y}^y i^2 = 2 \sum _{i=1}^y i^2 = 2 \frac{y (1+y) (1+2y)}{6}[/imath], I believe.
GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

brainfsck
Posts: 9
Joined: Sun Apr 05, 2009 12:05 am UTC

### Re: [Question] Random Numbers & Expected Stddev

GreedyAlgorithm wrote:
brainfsck wrote:Why does "a single number from U[-y,y] have mean 0 and stddev sqrt((y^2 + y) / 3)"? From this formula, I get that the stddev should be [imath]\sqrt{\frac{1}{2y}\sum _{i=-y}^y i^2} = \frac{\sqrt{(1+y) (1+2 y)}}{\sqrt{6}}[/imath].

Let's see... first off, that should be 1/(2y+1) instead of 1/2y, since in [-y,y] there are 2y+1 integers. Second, your summation should be [imath]\sum _{i=-y}^y i^2 = 2 \sum _{i=1}^y i^2 = 2 \frac{y (1+y) (1+2y)}{6}[/imath], I believe.

ok, I'm not sure what you mean by the summation mistake, but I fixed the 2y+1 denominator and it works now. Thanks

GreedyAlgorithm
Posts: 286
Joined: Tue Aug 22, 2006 10:35 pm UTC
Contact:

### Re: [Question] Random Numbers & Expected Stddev

Oh I see, yes, I missed that you had canceled the 2y and 1/2y. We agree, that seems to be the only difference.
GENERATION 1-i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.