Professional Documents
Culture Documents
第一組
電機四 B93902016 蔡馭理
資工四 B93902076 林宜鴻
1
Outline
2
Random Number Generator
Noise, interference
Random Number Generator-
computational or physical device designed
to generate a sequence of numbers or
symbols that lack any pattern, i.e. appear
random, pseudo-random sequence
MATLAB - rand(m,n) , randn(m,n)
3
Stationary and Ergodic Process
strict-sense stationary (SSS)
wide-sense stationary (WSS)
Gaussian
5
Example 7.1 (N=100)
x(t , ξ i ) A cos(2πft φi )
y nsemble-avarag(t) x nsemble-avarage(t)
1 0.5
x(t)
0 0
-1 -0.5
e
0 0.5 1 1.5 2 0 0.5 1 1.5 2
1 1
y(t)
0 0
-1 -1
e
0 0.5 1 1.5 2 0 0.5 1 1.5 2
z nsemble-avarag(t)
2 2
z(t)
0 0
-2 -2
e
7
Linear Congruence
8
Technique A: The Mixed Congruence
Algorithm
The mixed linear algorithm takes the form:
xi+1=[axi+c]mod(m)
- c≠0 and relative prime to m
- a-1 is a multiple of p, where p is the
prime factors of m
- a-1 is a multiple of 4 if m is a
multiple of 4
9
Example 7.4
m=5000=(23)(54)
c=(33)(72)=1323
a-1=k1‧2 or k2‧5 or 4‧k3
so, a-1=4‧2‧5‧k =40k
With k=6, we have a=241
xi+1=[241xi+ 1323]mod(5000)
We can verify the period is 5000, so it’s full
period
10
Technique B: The Multiplication Algorithm
With Prime Modulus
The multiplicative generator defined as :
xi+1=[axi]mod(m)
- m is prime (usaually large)
- a is a primitive element mod(m)
am-1/m = k =interger
ai-1/m ≠ k, i=1, 2, 3,…, m-2
11
Technique C: The Multiplication Algorithm
With Nonprime Modulus
The most important case of this generator
having m equal to a power of two :
xi+1=[axi]mod(2n)
The maximum period is 2n/4= 2n-2
the period is achieved if
- The multiplier a is 3 or 5
- The seed x0 is odd
12
Example of Multiplication Algorithm With
Nonprime Modulus
11
10
9 a=3
8
7
c=0
6
5
m=16
4
x0=1
3
1
0 5 10 15 20 25 30 35
13
Testing Random Number Generator
14
Scatterplots
Example 7.5
1 1 1
15
Durbin-Watson Test (1)
(1/N)n2 (X[n] X[n 1]) 2
N
D
(1/N)n2 X 2[n]
N
Let Y ρX 1 ρ 2 Z 1 ρ 1
16
Durbin-Watson Test (2)
Full period
Passes all applicable statistical tests for
randomness.
Easily transportable from one computer to
another
Lewis, Goodman, and Miller Minimum
Standard (prior to MATLAB 5)
xi+1=[16807xi]mod(231-1)
19
Mapping Uniform RVs to an Arbitrary pdf
U = FX (X) = Pr { X≦ x }
X = FX-1 (U)
FX-1(U) x
FX (X) = Pr { FX-1 (U) ≦ x }
= Pr {U ≦ FX (x) }
= FX (x)
21
Example 7.8 (1)
Setting FR(R) = U
r2
1 exp 2 U
2σ 22
Example 7.8 (2)
∵ RV 1-U is equivalent to U (have same pdf)
∴ r2
exp 2 U
2σ
Solving for R gives
R 2σ ln( U )
2
[n,xout] = hist(Y,nbins) -
bar(xout,n) - plot the histogram
23
Example 7.8 (3)
1500
Number of Samples
1000
500
0
0 1 2 3 4 5 6 7 8 9
Independent Variable - x
0.4
true pdf
Probability Density
0.2
0.1
0
0 1 2 3 4 5 6 7 8
Independent Variable - x 24
The Histogram Method
b M / a 0 xa
Mg X (x)
0, otherwise MgX(x)
M M/a=b
b max{ f X (x)}
fX(x)
a
gX(x)
1/a
0
0 x a 26
x+dx
Rejection Methods (2)
4
2 R2 x2 0xR
f X ( x) πR
0, otherwise
M 4 MgX(x)
R πR
fX(x)
gX(x)
1
R
0
0 R
28
Example 7.9 (2)
150
Number of Samples
100
50
0
0 1 2 3 4 5 6 7
Independent Variable - x
0.2
Probability Density
0.15
0.1
30
The Sum of Uniforms Method(1)
1.Central limit theorem
2.See next
N
1
Y B (U i )
. i 0 2
31
The Sum of Uniforms Method(2)
Expectation and Variance
N
1 1
E{U i } E{Y } B ( E{U i } ) 0
2 i 0 2
1 1/ 2 1 N
1 NB 2
var{U i } x 2 dx B var{Ui }
2 2
2 1/ 2 12 y
i 1 2 12
12
We can set to any desired value B y
N
Nonzero at y N 12 y 3N
2 N
32
The Sum of Uniforms Method(3)
Approximate Gaussian
Maybe not a realistic situation.
33
Mapping a Rayleigh to Gaussian RV(1)
34
Mapping a Rayleigh to Gaussian RV(2)
Transform
let x r cos and y r sin
1 y
x 2
y 2
r 2
and tan ( )
x
f R (r , )dAR f XY ( x, y)dAXY
dAXY ( x, y) dx / dr dx / d
r
dAR (r , ) dy / dr dy / d
r r2
f R (r , ) exp( 2 )
2 2
2
35
Mapping a Rayleigh to Gaussian RV(3)
From previous
X 2 2 ln(U1 ) cos 2U 2 Y 2 2 ln(U1 ) sin 2U 2
s s
v 2 2 ln( s)
Y 2 ln(U1 ) sin 2 U 2 2 ln( s)( ) v
2 2
s s
37
The Polar Method Alothgrithm
39
Establishing a Given Correlation Coefficient(2)
Mean,Variance,Correlation coefficient
E{Z } E{ X } E{Y } 0
E{ XY } E{ X }E{Y } 0
X2 Y2 E{ X 2 } ( E{ X }) 2 E{ X 2 } E{Y 2 } 2
E{[ X 1 Y ] }
2
Z
2 2
2 E{ X 2 } 2 1 2 E{ XY } (1 2 ) E{Y 2 }
2 2 (1 2 ) 2 2
40
Establishing a Given Correlation Coefficient(3)
E{ X } (1 ) E{ XY }
2
E{X 2 } 2
E{ XZ } 2
XZ
X Z
2
as desired
41
Pseudonoise(PN) Sequence Genarators
42
PN Generator implementation
43
Property of Linear Feedback Shift Register(LFSR)
45
Different seed for the PN generator
46
Family of M-sequences
47
Property of m-sequence
49
Signal Processing
Relationship
1.mean of input and output
2.variance of input and output
3.input-output cross-correlation
4.autocorrelation and PSD
50
Input/Output Means
51
Input/Output Cross-Correlation
53
Output Autocorrelation Function(2)
0 m 0
substitute previous equation R yy [ m]
Ryy [m] x2 h[ j]h[k ] (m k j)
j k
2
x h[ j]h[ j m]
j
54
Input/Output Variances
55
The End
Thanks for listening
56