y de Variables Aleatorias
Definiciones:
Los NMEROS ALEATORIOS son observaciones
independientes tomadas de una distribucin uniforme entre
0 y 1 [0,1].
f ( x ) = 1 if 0 x 1; 0 elsewhere. E ( x ) = 0.5; = 1 / 12
F ( x ) = 0 if x 0; F ( x ) = x 0 x 1; F ( x ) = 1
x 1
2
Las
VARIABLE
ALEATORIAS
son
obervaciones
independientes tomadas desde una distribucin especfica.
Una vez elegida la distribucin a partir de los datos
muestreados (e.g., para representar tiempos entre llegadas
de clientes/partes, tiempos entre reparaciones, etc.), el
programa de simulacin deber generar muestras aleatorias
independientes a partir de las distribuciones seleccionadas,
lo cual es realizado generando nmeros aleatorios y
aplicando transformaciones a estos nmeros para obtener
variables aleatorias.
zi = (azi-1+c) (mod m)
Procedimiento bsico:
1. Fijar z0 (valor de la semilla) igual a algn entero no negativo.
2. Fijar i =1.
3. Fijar zi = (azi-1+c) (mod m).
4. Fijar ui = zi/m, donde ui es el nmero aleatorio generado.
5. Fijar i = i + 1. Ir al paso 3.
Donde
ZI
5 10
10 9
15 4
6 5
11 0
16 7
7 12
12 3
17 6
8 15
13 2
18 1
4 11
9 14
14 13
19 8
ZI
ZI
ZI
Considere el
Z0 =1, 2, 3, y 4
El periodo es determinado por la semilla (largos de 16, 8,
16, 4, respectivamente). Por ejemplo, con Z0 =4: la
secuencia es 4, 52, 36, 20, 4.
(2 0)
>
2
k - 1, 1 -
donde k - 1, 1 - es el (1 - ) - cuantil
para una distribucin chi-cuadrado con
k - 1 g.l. (p. 709).
f(x)
Area achurada =
k21,1
No hay rechazo
Rechazo
F4 (x )
1.0
0.5
x (1) x (2)
x (3)
x (4)
Kolmogorov-Smirnov Test
donde:
D
D
si
> d
+
n
= m ax { D
+
n
, D
_
n
i
= m ax
F$ ( X
1 i n n
= m a x F$ ( X
1 i n
n , 1
(i )
(i )
i 1
5 o ms
.1
.4
.1
.3
.1
F(x)
0.6
0.5
0.1
x
1
et / = e t
Note that =
t0
F (t ) = 1 e t / = 1 e t
Also, 2 =
= 2
Let r = F (t ) = 1 e t
Then (1 r ) = e t and t = ln(1 r )
1
Hence, t = ln(1 r ) = ln(r )
Pasos: 1. Generar ri
2. Calcular ti = - ln (ri)
3. Repetir las veces necesarias
t0
25791
19991
31131
18765
22553
14327
12121
32535
F (x ) =
=
P r (X
x 3
0 .0 0 3
=
3
x ) =
0 .0 0 1 x
f(y )d y
F 1 = r = 0.001x 3, x = 3 1000r
x = (1000)(0.21) = 5.94
3
f ( x ) = .0 0 3 x
0
fo r x 0 ,
2
fo r 0 x 1 0 ,
fo r 1 0 x .
f (x )
10
Other Distributions
Uniform
1
f (t ) =
(b a )
a t b;
t a
Let r = F ( t ) =
ba
t a
F (t ) =
ba
then t = a + (b a ) r
Weibull
f (t ) = t e
( t / )
F (t ) = 1 e
( t / )
t 0
= r , hence t = [ ln(1 r )]
1/
Disadvantages:
The difficulty associated with finding the inverse of the cumulative
distribution function, F-1, in some cases
Not always the most efficient approach (i.e., other methods may
require less computation time)
Advantages:
Facilitates some variance reduction techniques (especially where
synchronization of random numbers is needed),
Easy to generate from truncated distributions,
Useful for generating order statistics....e.g., generate a random variate
which is the smallest of 5 random variables with identical distributions
(application: lifetime of a system with 5 identical components in series).
Convolution Methods
The probability distribution of a sum of 2 or more
independent r.v. is called a convolution of the
distributions of the original variables.
x ~ Erlang ( k , )
sum of k independent exponentially distributed r. v.,
X = x i where x i ~ exponential =
1
k
k
1
1
X =
ln (ri ) =
ln ( 1k ri )
1
k
k
Acceptance-Rejection Method
f(x)
x
b
a
c
Procedure: 1. Generate U1 and U 2 , both ~uniform(0,1)
2. Determine x=a+(b-a) U1 and f(x)
3. Determine whether U2 M > f(x)
If yes, reject x, go to 1
If no, accept x
Acceptance-Rejection Example
Let
f ( x) = 60 x (1 x)
3
Poisson Distribution
When there are n arrivals in one time unit and the average is
ln ri 1 <
n +1
ln ri
ln 1n ri > ln 1n +1ri
or 1n ri e > 1n +1ri
Non-Stationary Poisson
t
t
Procedure: 1. Set t = t i-1
1
2. Replace t by t * ln U 1
ti-1
ti
Generate U1 and U2
( t )
3. If U 2 * , set ti = t and return; otherwise, reject and repeat.
Normal Variates
z1 , z2 ~ iid N (0,1) z1 = B cos ; z2 = B sin
~ 2= 2
B 2 = z12 + z22
(equivalent to an expo(2))
B = ( 2 ln R )
1/2
z2 axis
z2
z1 axis
1/2
z2 = [ 2 ln(01758
.
.
.
)] sin(2 01489
) = 150
1/2
Binomial Distribution
1. Generate n U[0,1] values
2. Count how many values are <= p
3. The number found follows a b(x;n,p)
Geometric Distribution
Let
ln(1 r )
1
x = roundup
ln(1 p)
x is the number of trials before the first success,
x = 0, 1, 3,K
V (Y1 ) = V (Y2 ) = Y2
Otros Mtpdps
Convolucin
Acceptancin/Rechazo
Mtodos especiales de genracin de v.a.