about me
art
biz
Chess
corrections
economics
EconoSchool
Finance
friends
fun
game theory
games
geo
mathstat
misc
NatScience
... more
Profil
Logout
Subscribe Weblog

 
Have you played a video game lately? Purchased something on the web? Trained a Neural Network? Used a Genetic Algorithm for optimization? Run software from Microsoft? Applied textures to a photograph? Played the stock market? If the answer is "yes" to any of these questions, Random Number Generator (RNG) have affected your life[1].

Thank heavens I'm currently attenting a lecture on PRNGs! Here is a short summary of the first lecture (all proofs are surpressed ;-D):

Introduction to PRNGs: The output from a computer algorithm is deterministic, not random. What we require instead are algorithms that produce sequences of output that behave in important ways like sequences of realizations from random variables would behave. Such algorithmically created numerical sequences are termed random numbers, random variates, or random deviates to distinguish them from the (mathematically ideal) random variables they are intended to simulate. Just as random numbers are the fundamental building block of computer simulation studies, uniformly distributed random numbers are the building blocks for random numbers (and other random objects) with arbitrarily specified distributions. <> Physical methods of generating random numbers were known to the ancients; tossing coins and throwing dice are familiar examples. The advent of digital computers brought a need for lengthy streams of random numbers, and methods for generating them automatically were among the first general-purpose algorithms invented for the computing devices. Two fundamental types of uniform generators are in common use and are the basis for many variants: the linear congruential generators (LCGs) and the feedback shift-register (FSR) generators.[2]

In the first lecture of the RNG-course we dealt with LCGs - the 'simplest and unfortunately most widely employed PRNGs'[1]. The linear congruence method for generating pseudorandom numbers uses the linear recurrence relation (click here if you are not familiar with the notion of congruence): lcg01This PRNG is often denoted by lcg02 and uniform pseudorandom numbers in [0,1) are obtained by the transformation un := xn/m. Leamer proposed the generator LCG(108+1, 23, 0, 47594118) which had a repetition period of 5882352. The problem: LCGs allow an easy (number-) theoretical analysis based on the lattice structure formed by δ-dimensional vectors un = (un,...,un+δ-1) of all generated uniforms un.[3]

Example: Lattice structure of the infamous RANDU [LCG(231,65539,0,1)] randu This problem was pointed out by Marsaglia (1968) who wrote: "[A]ll multiplicative (b=0) congruential random number generators have a defect--a defect that makes them unsuitable for many Monte Carlo problems and that cannot be removed by adjusting the starting value, multiplier, or modulus. The problem lies in the "Crystalline" nature of multiplicative generators--if n-tuples (u1,u2,...,un), (u2,u3,...,un+1),... of uniform variates produced by the generator are viewed as points in the unit cube of n dimensions, then all the points will be found to lie in a relatively small number of parallel hyperplanes. Furthermore, there are many systems of parallel hyperplanes which contain all of the points; the points are about as randomly spaced in the unit n-cube as the atoms in a perfect crystal at absolute zero."

You may wish to read How to crack a Linear Congruential Generator. Makes somehow fun to play around. Here is my quick and dirty Mathematica implementation: lcgfun (nb, 5 KB) (I've seen that almost 100 readers downloaded the notebook on the logistic equation so far... how cool is that?)

[1] Not knowing your RNG could be costly: Random Generators - Why are they important? [2] Elements of Statistical Computing Volume 2 Draft Notes [3] A collection of classical pseudorandom number generators with linear structures
HedgeFundGuy meinte am 21. Mar, 15:49:
I just saw a History Channel show on a guy who used RNG to reverse engineer Keno machines. He worked for the gaming board and so had access to the base code. He knew the precise algorith used to generate numbers for a version of Keno at a certain casino, and wrote a program to reverse engineer the starting values based on the observed values.

Unfortunately, his accomplice (who was transmitting keno values back to him in his hotel room, where he could feed them into a computer) acted suspiciously after "winning", and hotel management noted that his roommate was a regulator. So he did not get the money, he got jail time. But it must have been fun. 
Mahalanobis antwortete am 21. Mar, 20:06:
Ritz Club Online Casino Terms and Conditions
3) END USER'S REPRESENTATIONS, bla bla
i) You will not reverse engineer, decompile, disassemble, modify, translate, make any attempt to discover the source code of the Casino Software, ....

Hey, I didn't reverse engineer your software, I'm Mr Lucky.

[From the Winners List (top recent winners):

Abdul 16-03-2005 European Roulette £7,265.00
Abdul 17-03-2005 European Roulette £2.997.00
Abdul 18-03-2005 European Roulette £6,000.00

Either this oil sheik plays every day or ...? ;-D]

b) You do not live in the United States, its Territories, France, Australia, South Korea, North Korea, Hong Kong, Austria or Alderney.

???

Poor Ritz Casino: A group of gamblers who won more than £1m at the Ritz Casino in London by using laser technology have been told by police they can keep their winnings. BBC
andy (guest) meinte am 4. Jun, 12:08:
Try to run lcgfun and warning occurs.
Solve::smod: Unable to solve equations for modulus.