Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Transformada Inversa
De composicin.
_
x
0
si U < p
0
x
1
si p
0
U < p
0
+ p
1
.
.
.
x
j
si p
0
+ + p
j 1
U < p
0
+ + p
j 1
+ p
j
.
.
.
P(X = x
j
) = P(p
0
+ + p
j 1
U < p
0
+ + p
j 1
+ p
j
) = p
j
.
Mtodo de la Transformada Inversa
F(x) = P(X x) : Funcin de distribucin acumulada
k=0
p
k
= p
0
+ p
1
+ + p
j
.
Grcamente
x
0
1
x
4
x
3
x
2
x
1
p
1
p
2
p
3
y = F(x)
p
0
x
0
1
x
4
x
3
x
2
x
1
p
0
p
1
p
2
p
3
X = x
2
p
0
+ p
1
< U < p
0
+ p
1
+ p
2
F(x)
Algoritmo
Si la v.a. toma un nmero nito de valores, el algoritmo es el
siguiente:
Algoritmo: Transformada Inversa
Generar U U(0, 1);
if U < p
0
then
X x
0
y terminar.
end
if U < p
0
+ p
1
then
X x
1
y terminar.
end
if U < p
0
+ p
1
+ p
2
then
X x
2
y terminar.
end
.
.
.
Algoritmo de la Transformada Inversa
Si x
0
< x
1
< x
2
< . . . , entonces F(x
j
) =
j
i =0
p
i
, y por lo tanto
X x
0
si U < p
0
= F(x
0
)
X x
j
si F(x
j 1
) U < F(x
j
)
Se trata de hallar el intervalo [F(x
j 1
), F(x
j
)) donde se ubica U:
U [F(x
j 1
), F(x
j
)) = Transformada Inversa
Ejemplo
X : {1, 2, 3, 4}.
p
1
= 0.20, p
2
= 0.15, p
3
= 0.25, p
4
= 0.40
Algoritmo
Generar U;
if U < 0.2 then
X 1 y terminar.
end
if U < 0.35 then
X 2 y terminar.
end
if U < 0.6 then
X 3
else
X 4
end
Orden decreciente de p
i
Si se ordenan de manera decreciente las probabilidades de masa
p
0
, p
1
, . . . , se puede obtener un algoritmo ms eciente:
Algoritmo: ordenando p
i
Generar U;
if U < 0.4 then
X 4 y terminar.
end
if U < 0.65 then
X 3 y terminar.
end
if U < 0.85 then
X 1
else
X 2
end
Generacin de una v.a. uniforme discreta
Si X U[1, n], entonces p
1
= p
2
= = p
n
=
1
n
.
X = j si
j 1
n
U <
j
n
j 1 nU < j
X = nU + 1
siendo x la parte entera (inferior) de x.
Ejemplo
Generar una variable aleatoria discreta X, con distribucin uniforme
en [5, 15].
Conjunto de 5 elementos: a, b, c, d, e.
Aplicaciones:
ordenarlos: U
i
1
< U
i
2
< < U
i
n
,
U
1
= 0.4, U
2
= 0.1, U
3
= 0.8, U
4
= 0.7.
U
2
< U
1
< U
4
< U
3
.
i =1
a(i )
n
siendo que n 1.
i =1
a(i )P(X = i ) =
n
i =1
a(i )
n
.
Generamos U
1
, U
2
, . . . , U
k
aleatorios en (0, 1), X
i
= nU
i
+ 1.
i =1
a(X
i
)
k
k grande
Clculo de promedios
Ejemplo
Utilizar 100 nmeros aleatorios para aproximar
S =
10000
i =1
e
i
10000
.
Promedio
S 0;
for i = 1 to 100 do
Generar U;
I 10000U + 1;
S S + exp(I/10000)
end
S S 100
Variable aleatoria geomtrica
P(X = i ) = pq
i 1
, i 1, q = (1 p).
Tenemos que F(j 1) = P(X j 1) = 1 P(X > j 1) = 1 q
j 1
.
log(q) es negativo,
i
i !
, i = 0, 1, . . .
Algoritmo 1: Generacin de una v.a. Poisson P()
Generar U U(0, 1);
i 0, p e
, F p;
while U F do
p = ( p)/(i + 1);
F = F + p;
i = i + 1
end
X i
Inconvenientes del Algoritmo 1
Denicin recursiva de p
i
: p
i +1
=
i + 1
p
i
, i 0.
p
i +1
p
i
si y slo si
i + 1
1, es decir, i + 1 .
El valor mximo de p
i
es p
El promedio de bsquedas es
1 + E [|X |] .
).
X
N(0, 1).
Promedio de bsquedas:
1 +
E
_
|X |
_
= 1 +
E[|Z|]
= 1 + 0.798
.
Variable Aleatoria Binomial B(n, p)
p
i
= P(X = i ) =
n!
i !(n i )!
p
i
(1 p)
ni
, i = 0, 1, . . . , n
El promedio de comparaciones es np + 1.
Generar U
1
, . . . , U
n
, y contabilizar cuntas son menores que p.
Es menos eciente pues requiere n comparaciones.
Valor ms probable: i = n p.
Promedio de bsquedas: 1 +
p
np(1 p) 0.798.