Download presentation
Presentation is loading. Please wait.
Published byHolly Banks Modified over 9 years ago
1
CS 450 – Modeling and Simulation Dr. X
2
Topics What Does Randomness Mean? Randomness in games Generating Random Values Random events in real life: measuring randomness
3
What is Randomness? Unpredictability? Does it characterize a single event or a sequence of events? From Wikipedia: Randomness means lack of pattern or predictability in events. Randomness suggests a non-order or non-coherence in a sequence of symbols or steps, such that there is no intelligible pattern or combination.ordercoherencesymbolssteps
4
Randomness in games
5
Probability 101 If you roll the dice twice, what is the probability of rolling two sixes?
6
Probability vs odds Odds = Favorable Outcomes / Unfavorable Outcomes Probability = Favorable Outcomes / All Outcomes
7
Probability 101 If you toss two coins what is the probability of HH?
8
Probability 101 Independent events Logical relations: – AND – OR
9
Defining Randomness How can a computer generate random numbers? Can we measure randomness?
10
Measuring Randomness Runs Test Frequency test Autocorrelation test Chi-square goodness of fit
11
Statistical Hypothesis test H 0 : Null Hypothesis, ex., a sequence of numbers is random H α : Alternative Hypothesis, ex., a sequence of numbers is NOT random Real Situation Decision H 0 is not rejectedH 0 is rejected H 0 is trueValidType I Error H 0 is not trueType II ErrorValid
12
Runs test Sequence of numbers X 1, …, X N Subtract X i+1 – X i Collect only the signs of the subtraction results Do the signs alternate ~50% of the time?
13
Frequency Test (Monobit test) Create a string S n = X 1 + X 2 + … + X n Calculate S obs = S n /n Calculate P-Value: P-value = erfc(S obs /2) where erfc: complementary error function If P-value > 0.01 accept the null hypothesis else reject
14
Autocorrelation Test Intuition: if the sequence of bits in e is random, then it will be different from another bit string obtained by shifting the bits of e by d positions.
15
Chi-Square Goodness of Fit Test Intuition: test checks whether a sequence of pseudo-random numbers in [0,1] are uniformly distributed If you have n numbers and split them in k groups, then if in the groups you have n/k numbers the distribution is normal Compare all observed values f i inside your kth group with the mean n/k If chi-square > theoretical x 2 obtained from table with k degrees of freedom, then null hypothesis rejected
16
Generating Random Numbers Congruential method Tausworthe generators Lagged Fibonacci generators The Mercenne Twister
17
Congruential Method x i+1 = ax i + c (mod m) a, c, m: non-negative If m is large, period of number repetition is large Conditions for full period: – m and c have no common divisor – a = 1 (mod r) if r is a prime factor of m – a = 1 (mod 4) if m is a multiple of 4
18
Tausworthe generators Additive congruential generators Modulus m is equal to 2 x i = (a 1 x i-1 + a 2 x i-2 +...+ a n x i-n ) (mod 2) where x i : 0 or 1 Mod 2 is equivalent to XOR
19
Lagged Fibonacci Generators Based on Fibonacci series: x n = x n-1 + x n-2 LFG: x n = x n-j O x n-k (mod m) where O: addition, or subtraction, or multiplication, or XOR
20
Mersenne Twister x k+n = x k+m ⊕ (x k u | x k+1 k )A, k≥0 Where x is the block of numbers of w bits
21
References The Guide to Computer Simulations and Games, By Katrin Becker and J.R.Parker, Wiley (Chapter 6) Computer Simulation Techniques: The Definitive Introduction, by Harry Perros, http://www4.ncsu.edu/~hp/simulation.pdf (Chapter 2) http://www4.ncsu.edu/~hp/simulation.pdf CS 45021
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.