You are on page 1of 11

Random Numbers

Aritra De Roll- Y0911009 3rd Year 5th Semester August 14, 2011

Introduction

This report discusses the randomness of the distributions generated by the various random number generators.The random generators that I have discussed here are the drand48() inbuilt function , linear congruence algorithm generator , and the logistics map generator. I have done 4 tests for all of them ( uniform distribution law test , correlation test , the plot of xi vsxi+1 vs probability and the plot of xi + xi+1 + ... + xi+10 vs probability).2 number is dened as : 2 2 = (x) The 2 can be checked against a standard table to determine the condence interval. The last test is a test of central limit theorem which states that
Abstract In probability theory, the central limit theorem states that the mean identically distributed random distributions mean of a suciently large number of independent random variables, each with nite mean and variance, will be approximately normally distributed.

Thus if we keep on plotting the sums of larger and larger number of random variables and plot it against the probability it will increasingly conform with a gaussian distribution.

2
2.1

DRAND48();
Uniform Distribution law test

In this test I have calculated the value of N (whose ideal value should be 1 as it indicated a universal distribution law).I have made use of various values of x and dx to calculated the number of numbers cropping up in the domain out of a trial of 100000 generations.And the average value that is being calculated to be 0.953276.

Table2_2 1.05

DRAND48()-(N)

value of N

0.95

0.9

0.85 0 20 40 60 80 100 120

The following table gives the 2 for the various degrees of freedom: 2 Degrees of freedom 0.9528 3 4.038 9 20.208 19 130.9 99

2.2

Correlation Plot

The scatter plot of xi vsxi+1 is given below where no detectable pattern is observed , so a conclusion can be drawn that there is minimum correlation between consecutively generated numbers.No decipherable patterns are obtained.

Correlation graph for Srand48()


1.2 1 0.8 0.6 0.4 0.2 0 -0.2 -0.2 0 0.2 0.4

Xi+1

XI

0.6

0.8

1.2

2.3

3rd Test

This is the plot between xI + xi+1 vs probability with the interval strength of 0.01.That gets me about 200 points that t out to for a triangular plot.The plot is attached down.
DRAND48()
0.012 0.01 0.008 Probability 0.006 0.004 0.002 0 -0.002 -0.5 0 0.5 1 xi +xi+1 1.5 2 2.5

2.4

The central limit theorem

This is the plot between xI + xi+1 + ... + xi+10 vs probability with the interval strength of 0.01.That gives 1000 points that ts into a gaussian distribution thus abiding by the central limit theorem.The gaussian curve is attached below.
DRAND48()
0.005

0.004

0.003 Probability

0.002

0.001

-0.001 -2 0 2 4 6 xi +xi+1+...+xi+10 8 10 12

Linear Congruence Algorithm Generator

The generator is of the form modN (a.p + b). Where the requirement is that a and b should be co-prime. I have used the following values : a=5111, b=428 ,N=13.

3.1

Uniform Distribution law test

The value of the uniform distribution coecient came out to be 0.957647. The plot of the various values is attached down.

Table2_2

LCA - (N)
1.04 1.02 1 0.98 value of N 0.96 0.94 0.92 0.9 0.88 0.86 0 20 40 60 80 100 120

The following table gives the 2 for the various degrees of freedom: 2 Degrees of freedom 4.6952 3 14.44 9 17.648 19 144.46 99

3.2

Correlation plot

The correlation plot is identically scattered except for statistical deviations.No decipherable patterns are obtained.

LCA
1.2 1 0.8 0.6 xi+1 0.4 0.2 0 -0.2 -0.2 0 0.2 0.4 xi 0.6 0.8 1 1.2

3.3

3rd test

The plot obtained is a triangular plot.


Generator-2
0.012 0.01 0.008 Probability 0.006 0.004 0.002 0 -0.002 -0.5 0 0.5 1 xi +xi+1 1.5 2 2.5

3.4

The Central limit theorem

Here also we obtain a gaussian plot.

Generator 2
0.005

0.004

0.003 Probability

0.002

0.001

-0.001 -2 0 2 4 6 xi +xi+1+...+xi+10 8 10 12

3.5

Conclusion

All in all , this generator can be concluded as an ecient random generator as it faired in all the 4 tests that was performed.But the coecients of the generator has to be chosen carefully in order to obtain perfectly random numbers.A bad selection of coecients can result in a biased generator as demonstrated below. The following are for the following values of a = 4096, b = 178 and N = 13.

1.2 1 0.8 0.6 xi+1 0.4 0.2 0 -0.2 -0.2 0 0.2 0.4 xi 0.6 0.8 1 1.2

0.03

0.025

0.02 probability

0.015

0.01

0.005

-0.005 -0.5 0 0.5 1 xi +xi+1 1.5 2 2.5

0.008

0.006

probability

0.004

0.002

-0.002 -2 0 2 4 6 xi +xi+1+ ... +xi+10 8 10 12

Logistic map generator

The following generator has been used: ai+1 = 4.ai .(1 ai ). I have taken every 20th number in the series. The initial number to be chosen to be around the middle.If it is near zero or one it can be seen that the random generators starts to asymptotically fall towards the extremes. 8

4.1

Uniform Distribution law test

The value of the uniform distribution coecient came out to be 0.77804.This is a poor result considering its deviation from the ideal value of one. The plot is expectedly an inverted parabola.
Logistic-(N)
3

2.5

value of N

1.5

0.5 -20 0 20 40 60 80 100 120

The following table gives the 2 for the various degrees of freedom: 2 Degrees of freedom 1145.5 3 3275.78 9 5761.34 19 12121 99

4.2

Correlation plot

There is a decipherable pattern here . The sides can be seen to be more populated.This was obtained after taking the initial value to be close to the middle.

Logistic correlation
1.2 1 0.8 0.6 xi+1 0.4 0.2 0 -0.2 -0.2 0 0.2 0.4 xi 0.6 0.8 1 1.2

4.3

3rd test

This plot is far from being a triangular plot.The number of randomly generated numbers.
3rd Test-Logistic
0.02

0.015

probability

0.01

0.005

-0.005 -0.5 0 0.5 1 xi +xi+1 1.5 2 2.5

4.4

The Central limit theorem

No gaussian plot is detected.

10

4th Test - Logistic


0.01

0.008

0.006 probability

0.004

0.002

-0.002 -2 0 2 4 6 xi +xi+1+ ... + xi+1 8 10 12

4.5

Conclusion

The logistic map generator is not an ecient random generator. It can be veried for the various tests done in it. One can notice the similarity of the plots for the second , third and the fourth tests for this and an improper LCA generator. Moreover there is also large value of dierence in the 2 number than the other two.I have used every 20th number . Basically what it does is to create a hugely varying polynomial function.It would produce more randomly if larger intervals are considered.

11

You might also like