written 8.5 years ago by | • modified 4.6 years ago |
written 8.5 years ago by |
It is necessary to test random numbers because the random numbers we generate are pseudo random numbers and not real and pseudo random number generator must generate a sequence of such random numbers which are uniformly distributed and they should not be correlated, they should not repeat itself.
In short we can say test is necessary to determine whether the stream of number is random.
Hypothesis testing is used to test uniformity and independence properties of random numbers. Kolmogorov Smirnov (K-S) test and Chi-Square is used to compare distribution of the set of numbers generated to a uniform distribution.
Methods for generation of pseudo Random numbers are as follows
Linear Congruential Method
Combined Linear Congruential Method.
Linear Congruential method can be divided into Mixed L.C.M and Multiplicative L.C.M Method.
Linear Congruential Method:The linear method was initially proposed by lehmer in 1951. This method produces a sequence of integers, X1, X2… between zero and m-1 by following a recursive relationship.
$X_{i+1}$=(a$X_i$+c)mod m, i=0,1,2,…
Where $X_0$ is called as seed.
a is the multiplier
c is increment,
and m is modulus.
If c is not equal to 0 then the form is called as mixed congruential method.
And when c is equal to 0 the form is called as multiplicative congruential method. The selection of values for a, c, m, and X0 drastically affects the statistical properties and cycle length.
Combined Linear Congruential Method: Due to increase in complexity, reliability and problem size the generator with longer period is required. This problem is overcome by combine L.C.M. Here random numbers are generated by following relation.
Xi= ∑($(-1)^{j-1}X_{i,j}$) mod $m_1$-1
Then $R_i= X_1/m_1$ ; $X_i$>0
=$(m_1-1)/m_1$ ; $X_i=0$
Maximum possible period for such generator is
P=$((m_1-1)*(m_2-1)*...(m_k-1))/2^{k-1}$
A sequence of random numbers must have following important properties uniformity and independence.
Every single random number should be independent sample drawn from a continuous uniform distribution between zero and 1 – this pdf is given by
f(x) = 1; 0<x<1< p="">
= 0; otherwise.
Independence property: This property states that in a given sequence or series of random numbers should not depend on its previous number.
Uniformity property: This property means if we divide all the set of random numbers into several numbers of class interval then number of samples in each class should be same. If ‘N’ number of random samples is divided into ‘K’ class interval then expected number of samples in each class should be equal to ei=N/K, where ei is expected Number of samples in each interval.
Other two properties of random numbers are as follows.
Maximum Density: It states that large samples should be generated in a given range.
Maximum Cycle: This property states that the repetition of numbers should be allowed after a large interval of time.