Presentation is loading. Please wait.

Presentation is loading. Please wait.

Genetic Algorithms Can Be Used To Obtain Good Linear Congruential Generators Presented by Ben Sproat.

Similar presentations


Presentation on theme: "Genetic Algorithms Can Be Used To Obtain Good Linear Congruential Generators Presented by Ben Sproat."— Presentation transcript:

1 Genetic Algorithms Can Be Used To Obtain Good Linear Congruential Generators Presented by Ben Sproat

2 Outline Linear Congruential Generators Linear Congruential Generators What are they? What are they? Why do we need a Genetic Algorithm? Why do we need a Genetic Algorithm? Genetic Algorithm Genetic Algorithm What are they? What are they? What do we need to use one? What do we need to use one? Putting them together Putting them together How do we decide if we have a good LCG? How do we decide if we have a good LCG? Results Results

3 Linear Congruential Generators Currently one of the most popular Pseudorandom Number Generator Currently one of the most popular Pseudorandom Number Generator Proposed by Lehmer in 1948 Proposed by Lehmer in 1948 Xn+1 = (a * Xn + b) mod m where Xo=seed Xn+1 = (a * Xn + b) mod m where Xo=seed Easy to implement and very fast Easy to implement and very fast

4 Simple LCG a= 7, b=2, m=17, Xo=9 a= 7, b=2, m=17, Xo=9 X1= (7 * 9 +2) mod 17 = 14 X1= (7 * 9 +2) mod 17 = 14 X2= (7 *14 +2) mod 17 = 15 X2= (7 *14 +2) mod 17 = 15 X3= (7 *15 +2) mod 17 = 5 X3= (7 *15 +2) mod 17 = 5 X4= (7 * 5 +2) mod 17 = 3 X4= (7 * 5 +2) mod 17 = 3 X5= (7 * 3 +2) mod 17 = 6 X5= (7 * 3 +2) mod 17 = 6

5 Problems With LCG’s Vulnerable to certain types of attacks Vulnerable to certain types of attacks Should not be used as key generators Should not be used as key generators Given certain choices for a, b, and m the numbers it produces may not be very useful Given certain choices for a, b, and m the numbers it produces may not be very useful Requires looking up good values for a, b, and m Requires looking up good values for a, b, and m Many programmers use pseudorandom techniques to pick a, b, and m Many programmers use pseudorandom techniques to pick a, b, and m

6 A bad LCG a= 1, b=4, m=8, Xo=5 a= 1, b=4, m=8, Xo=5 X1= (1 * 5 +4) mod 8 = 1 X1= (1 * 5 +4) mod 8 = 1 X2= (1 * 1 +4) mod 8 = 5 X2= (1 * 1 +4) mod 8 = 5 X3= (1 * 5 +4) mod 8 = 1 X3= (1 * 5 +4) mod 8 = 1 X4= (1 * 5 +4) mod 8 = 5 X4= (1 * 5 +4) mod 8 = 5 X5= (1 * 3 +4) mod 8 = 1 X5= (1 * 3 +4) mod 8 = 1

7 Genetic Algorithms Blind, stochastic near-optimal heuristic search method Blind, stochastic near-optimal heuristic search method Uses a fitness function to select potential chromosomes to be reproduced Uses a fitness function to select potential chromosomes to be reproduced Uses Genetic operators to reproduce Uses Genetic operators to reproduce Uses a Convergence criteria to decide when to stop Uses a Convergence criteria to decide when to stop

8 Crossover and Mutation Chromosome 1=1010 1110 Chromosome 1=1010 1110 Chromosome 2=1100 0110 Chromosome 2=1100 0110 Crossover Chromosome 1= 1010 0110 Crossover Chromosome 1= 1010 0110 Crossover Chromosome 2=1100 1110 Crossover Chromosome 2=1100 1110 Mutant Chromosome 1=1011 1110 Mutant Chromosome 1=1011 1110 Mutant Chromosome 2=1100 0100 Mutant Chromosome 2=1100 0100

9 The Genetic Algorithm A population of N chromosomes is generated A population of N chromosomes is generated N chromosomes are selected randomly using the fitness function to determine proportions N chromosomes are selected randomly using the fitness function to determine proportions Two chromosomes are selected at random and crossed over and put in the new population repeat until the pool is empty Two chromosomes are selected at random and crossed over and put in the new population repeat until the pool is empty Mutate all the new Chromosomes Mutate all the new Chromosomes Test if the convergence criteria has been met Test if the convergence criteria has been met If not repeat If not repeat

10 Fitness Functions For our Problem There are many ways to determine a good LCG There are many ways to determine a good LCG May depend on what it will be used for May depend on what it will be used for There is really no good way to determine if an LCG is good or bad, so a battery of tests is normally used There is really no good way to determine if an LCG is good or bad, so a battery of tests is normally used

11 Statistical Tests For Randomness Entropy: information density of the output of one cycle of the generator Entropy: information density of the output of one cycle of the generator Chi-Square percentile: no LCG passes this test Chi-Square percentile: no LCG passes this test Arithmetic mean: the mean of the numbers generated should be approximately m/2 Arithmetic mean: the mean of the numbers generated should be approximately m/2 Monte Carlo value for Pi: random numbers can be used to calculate Pi! Monte Carlo value for Pi: random numbers can be used to calculate Pi!

12 Statistical Tests For Randomness Serial Correlation Coefficient: bit based dependency check Serial Correlation Coefficient: bit based dependency check Maximal Period: The maximal period for an LCG is m Maximal Period: The maximal period for an LCG is m Percentage of the maximum period achieved: Percentage of the maximum period achieved:

13 Results Fitness = entropy Fitness = entropy Fitness = entropy + period Fitness = entropy + period Fitness = entropy + period / maxperiod Fitness = entropy + period / maxperiod Fitness = entropy * period / maxperiod Fitness = entropy * period / maxperiod

14 abm1234 150058371199937.9830.01132.74.26% 623710697210237.9850.01132.95.12% 143599654215697.9850.01132.33.49% 1258611658210237.9850.01132.75.25% 451815578211797.9850.01132.02.30% 127110331209837.9850.01132.33.69% 65334712210117.9850.01132.94.32% 1: Per byte entropy (optimum = 8.0) 2: Chi-Square percentile 3: Arithmetic mean (optimum = 127.5) 4: Error % in the estimation of Pi

15 Conclusion LCG’s are useful Pseudorandom Number Generators LCG’s are useful Pseudorandom Number Generators You must be careful in selecting your LCG You must be careful in selecting your LCG Genetic Algorithms are a fast way of generating good LCG’s Genetic Algorithms are a fast way of generating good LCG’s A good fitness function is essential A good fitness function is essential

16 Questions?


Download ppt "Genetic Algorithms Can Be Used To Obtain Good Linear Congruential Generators Presented by Ben Sproat."

Similar presentations


Ads by Google