Download Pseudorandom Number Generators Outline Pseudorandom

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Outline
Pseudorandom Number
Generators



M. Sami Fadali
University of Nevada

Are they random?
How do we generate “random”
numbers for simulation?
How do we generate “random”
numbers for experiments?
MATLAB
2
1
Pseudorandom Numbers




Example
Appear random.
Deterministic.
Needed for experiments and
simulations.
MATLAB




3
Obtain a sample realization of a GaussMarkov process.
Record of duration
.
Play record in a loop (i.e. periodic).
Appears random but clearly
deterministic.
4
Spectrum



Shift Register

Discrete (line) spectrum for a periodic signal.
Lines of spectrum are
apart.
Envelope of lines.
Y
்

1.
ଶ
ଶ
ଶ
2.
ଶ
Generate binary sequence using a shift
register with feedback.
Each clock pulse:
Shift right.
Add XOR(aright,amiddle) to left.
+
ଶ
Y
்
ଶ
output
ଶ
0
11 1 1 1
1
5
Is it random?




6
Plots of Binary Waveform
Repeats after 2n1 bits.
Almost half ones and half zeros (e.g n=10,
512 ones and 512 zeros).
Fixed sequence for fixed initial seed and
feedback.
Completely deterministic but appears random.
7
Seed = {1, 1, 1, 1, 1}
Sequence={1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, …}
8
Mermistor
Uniform Pseudorandom
Mermistor: true random number generator.
 Used for low power logic.
 See IEEE Spectrum July 2012
http://spectrum.ieee.org/semiconductors/me
mory/a-memristor-true-randomnumbergenerator/?utm_source=techalert&utm_mediu
m=email&utm_campaign=071912

rand: generates arrays of random numbers
uniformly distributed in the interval (0,1)
 Z = rand(m,n) or Z = rand([m n])
returns an m-by-n matrix of random entries
Z = rand % returns a scalar.
Z ~U[0,1], uniform over the interval.
 Y = (max-min)*Z + min % Y ~U[min, max]
 height= 1/(max  min)
9
10
Theorem (Hogg et al., p. 288)
If the random variable
then,
for any continuous distribution function ,
ିଵ
the random variable
.
 Assume that
is monotone increasing
to simplify the proof (one-one).
 Use the theorem to generate many
distributions using the uniform
distribution.
Proof
௎
ିଵ
ி ௫
1
௎
0.8
0.6
଴
0.4
0.2
0
-1
11
-0.5
0
0.5
1
1.5
2
12
Example: Exponential Distrib.
Gaussian Pseudorandom
randn: Normally distributed random numbers
and arrays.
 Z = randn(m,n) or Z = randn([m n])
returns an m-by-n matrix of random entries.
 Z = randn
% returns a scalar.
Z ~N (0,1),
Y = sigma*Z + mean, Y ~N(mean, sigma2)
ି௫
X

Inverse of Exponential Distribution
ିଵ
X
13
Statistics Toolbox
14
Gaussian
Generates random numbers with other
distributions using rand/randn.
 Commands in the form xxxrnd
 xxx=name of distribution
Examples: chi2rnd (Chi-square), binornd
(binomial), poissrnd (Poisson), etc.

15
Z ~N(mean, sigma2)
>>mean=1;sigma=2;m=2;n=1;
>>Z = normrnd(mean, sigma, m,n)
Z=
0.1349
-2.3312

16
Random
Uniform
Uses the name of the distribution as a
parameter (Normal, Poisson, Chi2)
>> rn = random('Normal',1,4,2,3)
% mean 1, var =4, 2 by 3 matrix
rn =
0.6174 2.1776 3.8573
-2.3294 -4.3447 7.4942
Z ~U[min, max]
 height= 1/(max  min)
>> min=1.1;max=2;
random('Uniform',min,max,1,3)
% 1 by 3 array with uniform pdf
ans =
1.9551 1.3080 1.6462

17
Interesting Web Sites

Conclusion
http://www.agner.org/random/

Programs for generating uniform and nonuniform

distributions.

J. E. Gentle, Random Number Generation and Monte

Carlo Methods, Springer-Verlag, NY, 2003.

18
Pseudorandom not random.
Monte Carlo simulation.
Application in physics, engineering,
biology, etc.
http://www.mathworks.com/moler/random.pdf
MATLAB random number generator: for all commands
 Controlling the random number generator: rng
>> rng(sd) % sd = nonnegative integer seed
19
20
Related documents