Why does the average of a set of random numbers to the nth power approach 1/(n+1)?

25 Views Asked by At

I got bored and started running a Java program to mess with stuff like this. I did a boatload of trials and averaged them all together, first for a random number squared. Quick pseudo-code:

total = 0
for (i = 0; i < 1000000; i++) {
total+= randomNum^2
}
avg = total/1000000

For this instance it would approach 0.333333. The square root would approach 0.66666. I figured out the pattern to be (1/(power + 1)). Can anyone explain mathematically why this is?

1

There are 1 best solutions below

0
On BEST ANSWER

The program given computes Monte Carlo integration of $$\int_0^1 x^2dx$$ We can also compute this exactly, as $\frac{x^3}{3}|_0^1=\frac{1}{3}$. More generally, replacing $2$ by $n$, the integral will equal $\frac{1}{n+1}$ (provided $n\neq-1$).