Random Number Generators - Mathematics Department
合集下载
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
– Standard seed for these equations
Overflow & Negative Numbers
Using large values of a and large values of M are needed
– Often 31 bits long
On 32 bit machines
Large scale tests cause most problems
– Needing sometimes millions or billions of random numbers
Desirable Properties
When performing Monte Carlo Simulations
Problems
Difficult to isolate
– Often need to replace current generator – Require
Knowledge of current generator Sometimes in-depth understanding of
random number generators themselves
Equations - LCG
Using LCG
Choosing Correct Input is Key LCG (a,c,m,X0)
– LCG (5, 1, 16, 1)
Yields –
1,6,15,12,13,2,11,8,9,14,7,4,5,10,3,0, 1,6,15,12,13,2,11,8,9,14,…
Random Number Generators - Mathematics Department - …随机数发生器-数学系—…
Random Number Generators
Based upon specific mathematical algorithms
Which are repeatable and sequential
Introduction cont…
Major components of Monte Carlo methods:
– Probability distribution functions – Random number generator – Scoring – Error estimation – Variance reduction techniques – Parallelization and vectorization
– Attributes of each particle should be independent of those attributes of any other particle
– Fill the entire attribute space in a manner which is consistent with the physics
– Must keep L words current in memory – LCG needs only one
LFG (cont)
LFG are an attempt to improve LCG Similar to Combined LCG
– Take 2 previous numbers in the sequence to produce a new number
Introduction cont…
MC method is often referred to as the “method of last resort”, as it is apt to consume large computing resources;
Characteristics: – consuming vast computing resources – have historically had to be executed upon the fastest computers available at the time – and employ the most advanced algorithms – implemented with substantial programming acumen.
– Correlation (each differ by 4)
Cycle (5,0,16,1)
Seed
Using the date and time
– Enter the date and time into an equations and return an integer then make sure it is odd
Random
Truly Random
– Exhibiting true randomness
Pseudorandom
– Appearance of randomness but having a specific repeatable pattern
Quasi-random
– Having a set of non-random numbers in a randomized order
Requires initial “seed” denoted as X0 Appears random because of Modulo function Next “random” number depends heavily on
previous X
– Typical of linear, congruential generators – Restricts period
– Lags are k and l – M is power of 2
With proper choice of k and L Period of Generator can be
– [(2^L)-1] * [2^(m-1)]
LFG
Computationally simple
– Integer add – Logical AND – Decrement of 2 array pointers
– The sequence gets traversed in a particular order
– The sequence repeats if the period of the generator is exceeded
LCG
Most commonly used RNG
– Linear Congruential Generator
When the next result depends upon only the previous integer, the longest period possible is P=M
Odd/Even pattern lack of randomness results from using a power of two
surrounding area.
Plot these points in succession The area will be uniformly covered by r
– Covering of only part of the unit or certain areas of the unit would prove to be not useful for Monte Carlo Methods
Embarrassingly Parallel'
Little or no interprocessor communication
Easy to code
N Streams
N Streams
– N independent random numbers – N independent processes
Need to find N seeds far away from each other on the cycle
Find Seeds
Find Seeds
– LCG rule successively applied:
Lagged Fibonacci Generators
Increasingly popular
Can be presented in either Integer or Real numbers
Cycle
What Does This Show Us?
Properties of pseudorandom sequences of integers
– The sequence has a finite number of integers
– A*M results in 62 bit number – Overflow
Can result in 32nd bit being a negative
N-Tuple Generalization
Choose R1 and R2
– Choose Rn and R(n+1) – Then plot this point of interest in a
Random Number Cycle
Basis
– sequence of pseudorandom integers
Some exceptions
Integers (“Fixed”)
– Manipulated arithmetically to yield floating point (“real”)
for M
Cycle LCG(5,1,16,1)
Table
Example #2
LCG(5,0,16,1)
– Yields - 1,5,9,13,1,5,9,13,… – M is a power of 2 (here: 2^4)
C=0 Maximum period is going to be 2^(m-2)
Introduction cont…
Similarly, Monte Carlo methods randomly select values to create scenarios of a problem. These values are taken from within a fixed range and selected to fit a probability distribution [e.g. bell curve, linear distribution, etc.]. This is like rolling a dice. The outcome is always within the range of 1 to 6 and it follows a linear distribution - there is an equal opportunity for any number to be the outcome.
Introduction
Define Monte Carlo Method
– The Monte Carlo method is a numerical method for solving mathematical problems using stochastic sampling.
– It performs simulation of any process whose development is influenced by random factors, but also if the given problem involves no chance, the method enables artificial construction of a probabilistic model.
– Where p and q are the “lags” – Some arithmetic computation is performed – Then mod that answer for the next number
Monte Carlo Methods
Overview
Introduction History Examples Applications Real Life practices
Overflow & Negative Numbers
Using large values of a and large values of M are needed
– Often 31 bits long
On 32 bit machines
Large scale tests cause most problems
– Needing sometimes millions or billions of random numbers
Desirable Properties
When performing Monte Carlo Simulations
Problems
Difficult to isolate
– Often need to replace current generator – Require
Knowledge of current generator Sometimes in-depth understanding of
random number generators themselves
Equations - LCG
Using LCG
Choosing Correct Input is Key LCG (a,c,m,X0)
– LCG (5, 1, 16, 1)
Yields –
1,6,15,12,13,2,11,8,9,14,7,4,5,10,3,0, 1,6,15,12,13,2,11,8,9,14,…
Random Number Generators - Mathematics Department - …随机数发生器-数学系—…
Random Number Generators
Based upon specific mathematical algorithms
Which are repeatable and sequential
Introduction cont…
Major components of Monte Carlo methods:
– Probability distribution functions – Random number generator – Scoring – Error estimation – Variance reduction techniques – Parallelization and vectorization
– Attributes of each particle should be independent of those attributes of any other particle
– Fill the entire attribute space in a manner which is consistent with the physics
– Must keep L words current in memory – LCG needs only one
LFG (cont)
LFG are an attempt to improve LCG Similar to Combined LCG
– Take 2 previous numbers in the sequence to produce a new number
Introduction cont…
MC method is often referred to as the “method of last resort”, as it is apt to consume large computing resources;
Characteristics: – consuming vast computing resources – have historically had to be executed upon the fastest computers available at the time – and employ the most advanced algorithms – implemented with substantial programming acumen.
– Correlation (each differ by 4)
Cycle (5,0,16,1)
Seed
Using the date and time
– Enter the date and time into an equations and return an integer then make sure it is odd
Random
Truly Random
– Exhibiting true randomness
Pseudorandom
– Appearance of randomness but having a specific repeatable pattern
Quasi-random
– Having a set of non-random numbers in a randomized order
Requires initial “seed” denoted as X0 Appears random because of Modulo function Next “random” number depends heavily on
previous X
– Typical of linear, congruential generators – Restricts period
– Lags are k and l – M is power of 2
With proper choice of k and L Period of Generator can be
– [(2^L)-1] * [2^(m-1)]
LFG
Computationally simple
– Integer add – Logical AND – Decrement of 2 array pointers
– The sequence gets traversed in a particular order
– The sequence repeats if the period of the generator is exceeded
LCG
Most commonly used RNG
– Linear Congruential Generator
When the next result depends upon only the previous integer, the longest period possible is P=M
Odd/Even pattern lack of randomness results from using a power of two
surrounding area.
Plot these points in succession The area will be uniformly covered by r
– Covering of only part of the unit or certain areas of the unit would prove to be not useful for Monte Carlo Methods
Embarrassingly Parallel'
Little or no interprocessor communication
Easy to code
N Streams
N Streams
– N independent random numbers – N independent processes
Need to find N seeds far away from each other on the cycle
Find Seeds
Find Seeds
– LCG rule successively applied:
Lagged Fibonacci Generators
Increasingly popular
Can be presented in either Integer or Real numbers
Cycle
What Does This Show Us?
Properties of pseudorandom sequences of integers
– The sequence has a finite number of integers
– A*M results in 62 bit number – Overflow
Can result in 32nd bit being a negative
N-Tuple Generalization
Choose R1 and R2
– Choose Rn and R(n+1) – Then plot this point of interest in a
Random Number Cycle
Basis
– sequence of pseudorandom integers
Some exceptions
Integers (“Fixed”)
– Manipulated arithmetically to yield floating point (“real”)
for M
Cycle LCG(5,1,16,1)
Table
Example #2
LCG(5,0,16,1)
– Yields - 1,5,9,13,1,5,9,13,… – M is a power of 2 (here: 2^4)
C=0 Maximum period is going to be 2^(m-2)
Introduction cont…
Similarly, Monte Carlo methods randomly select values to create scenarios of a problem. These values are taken from within a fixed range and selected to fit a probability distribution [e.g. bell curve, linear distribution, etc.]. This is like rolling a dice. The outcome is always within the range of 1 to 6 and it follows a linear distribution - there is an equal opportunity for any number to be the outcome.
Introduction
Define Monte Carlo Method
– The Monte Carlo method is a numerical method for solving mathematical problems using stochastic sampling.
– It performs simulation of any process whose development is influenced by random factors, but also if the given problem involves no chance, the method enables artificial construction of a probabilistic model.
– Where p and q are the “lags” – Some arithmetic computation is performed – Then mod that answer for the next number
Monte Carlo Methods
Overview
Introduction History Examples Applications Real Life practices