1 / 16

Genetic Algorithms Can Be Used To Obtain Good Linear Congruential Generators

Explore how Genetic Algorithms enhance Linear Congruential Generators, popular PRNGs with potential issues. Learn how fitness functions and statistical tests can improve LCG efficiency.

Download Presentation

Genetic Algorithms Can Be Used To Obtain Good Linear Congruential Generators

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

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

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

  5. Problems With LCG’s • Vulnerable to certain types of attacks • Should not be used as key generators • 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 • Many programmers use pseudorandom techniques to pick a, b, and m

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

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

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

  9. The Genetic Algorithm • A population of N chromosomes is generated • 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 • Mutate all the new Chromosomes • Test if the convergence criteria has been met • If not repeat

  10. Fitness Functions For our Problem • There are many ways to determine a good LCG • 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

  11. Statistical Tests For Randomness • Entropy: information density of the output of one cycle of the generator • Chi-Square percentile: no LCG passes this test • 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!

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

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

  14. 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 • You must be careful in selecting your LCG • Genetic Algorithms are a fast way of generating good LCG’s • A good fitness function is essential

  16. Questions?

More Related