Testing my uniform distribution

146 Views Asked by At

i have two vectors (15 elements and 120 elements) of numbers that i generated with Linear congruential generator U[-1,1) in python and now i have to test them for uniform distribution . I need help choosing a test and running it (i cant do to this with any built-in test, I have to do this by my self with calculations). Anyone can help me with choosing a test and showing me any solustions? I think I know how to conduct tests but i need help with choosing it. I dont know am I right but first i should start with testing mean with t student test ?

Thank you in advance for your help

Mean for 15 elements: 0.037882

Mean for 120 elements 0.06044

SD for 15: 0.502921

SD for 120: 0.593756

1

There are 1 best solutions below

2
On

(a) Instructions seem vague and it would be easier to know what approach you are supposed to take if we knew what topics in statistics you have studied already--especially recently. (b) Also, you do not say specifically what distribution your LCG is programmed to generate.

One reason we ask you to show your work so far, it that your work may provide some context, even for vague problems. Such information is missing in your question.

I will answer briefly assuming in (a) that you know about z -tests and in (b) that your 'random' numbers are supposed to be indistinguishable from $\mathsf{Unif}(0,1).$ I understand that these guesses may be wrong. If so, maybe you can revise your question with more context so that someone else will make better assumptions.

From the Central Limit Theorem one would expect the mean of $n$ such random variables should be approximately $\mathsf{Norm}\left(\mu = 1/2, \sigma = \sqrt{\frac{1/12}{n}}\right)$ because the mean and variance of the standard uniform distribution are $1/2$ and $1/12,$ respectively.

Means of samples of 120 properly generated standard uniform random variables are extremely close to normally distributed. Even for samples of $n=15,$ means are nearly normal.

Using z-scores to asses LCG. So you can find the z-score $z = \frac{\bar X = 1/2}{\frac{1/12}{n}}$ for each of your samples and reject the null hypothesis that the LCG is performing properly if $|z| > 1.96.$

For example, your second sample has $z = \frac{0.0604 - .5}{\sqrt{1/12}{120}} \approx -16.7,$ which obviously leads to rejection.

(0.0604 - 1/2)/sqrt((1/12)/120)
[1] -16.68165

Simulated results for means of properly generated standard uniform samples. The following simulation in R looks at results for 100,000 samples $n=120$ observations drawn from a well-vetted random number generator.

set.seed(113)
a = replicate(10^5, mean(runif(120)))
summary(a); sd(a)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.3812  0.4822  0.5000  0.5001  0.5179  0.6185 
[1] 0.02637311

The 100,000 sample means $\bar X$ (vector a in the code) average about .5 and are never below 0.38 or above 0.52.

So for the second sample, the mean $\bar X = 0.0604$ seems an essentially impossible value for the mean of 120 actual observations from a standard uniform distribution.

You might also ponder why the standard deviation 0.593756 of this sample is so far from the anticipated value $\sqrt{\frac{1/12}{120}} = 0.0264.$