Frage

If Random.rand generates a number with a uniform distribution between 0 and 1, what kinds of distributions do you get by addition of 'Random.rand' calls and dividing by the number of calls?

in in other words, what kinds of distributions do you get with the following?

(Random.rand + Random.rand)/2

(Random.rand + Random.rand + Random.rand)/3

War es hilfreich?

Lösung

The probability density function (pdf) of the average of two Uniform(0,1) random variables is linear - going up until 0.5, then down. The pdf of the average of 3 Uniform(0,1) random variables is broken into 3 pieces, each of which is a quadratic function. And so on, with each successive addition of a Uniform(0,1) random variable increasing the degree of the polynomial and the number of pieces.

The distribution of the mean of k Uniform(0,1) random variables is called a Bates distribution.

Andere Tipps

If a random variable (RV) has a distribution with finite variance (a uniform qualifies), then sums of those random variables converge in distribution to the Normal/Gaussian distribution as the number of terms in the sum increases. This is known as the central limit theorem. The rate of convergence depends on whether the underlying RVs are continuous or discrete, symmetric or skewed, and independent or correlated. Independent observations from symmetric continuous distributions, such as the uniform, have a rapid rate of convergence.

A sum or average of two independent uniforms has a symmetric triangular distribution. I don't know any name for larger sums other than "convolution of k uniforms", but the larger k is the more it gets curvy in the middle and tapered towards the ends and looks like a normal. By the time you get up to k = 12, you need a fairly large sample size to be able to reject the hypothesis that the sum or average is normal.

If you are averaging k independent Uniform(0,1)'s, the expected value of the average will be 0.5 and the variance will be 1/12k.

well, it converges on 0.5 obviously...

EXPECTED_VALUE = 0.5
DELTA = 0.0001

arr = []
10_000_000.times{arr << rand}
(EXPECTED_VALUE - (arr.inject(&:+) / arr.count)).abs < DELTA
=> true
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top