monte carlo - milidiu/inf2981/aulas/13_acceptance... a agulha de buffon georges-louis leclerc –...
TRANSCRIPT
![Page 1: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/1.jpg)
Ruy Luiz Milidiú
Monte Carlo
![Page 2: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/2.jpg)
Monte Carlo
![Page 3: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/3.jpg)
Monte Carlo
![Page 4: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/4.jpg)
Monte Carlo
![Page 5: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/5.jpg)
A Agulha de Buffon
Georges-Louis Leclerc – Conde de Buffon, 1777
Elementos
uma agulha
um piso
Experimento
Lançar a agulha ao piso
![Page 6: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/6.jpg)
A agulha
![Page 7: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/7.jpg)
O piso
![Page 8: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/8.jpg)
Lançamento
![Page 9: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/9.jpg)
Lançamento
![Page 10: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/10.jpg)
Lançamento
![Page 11: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/11.jpg)
Lançamento
![Page 12: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/12.jpg)
Contagens
Lançamentos 8
Cortes 5
![Page 13: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/13.jpg)
Estimativa de
cortes
slançamento.2
![Page 14: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/14.jpg)
Estimativa de
2.3
5
8.2
![Page 15: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/15.jpg)
Corte
d
sin21
sin21d
![Page 16: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/16.jpg)
Accept–reject
sin21d
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
![Page 17: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/17.jpg)
Accept–reject
sin21d
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
accept
![Page 18: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/18.jpg)
Accept–reject
sin21d
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
accept
![Page 19: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/19.jpg)
Accept–reject
sin21d
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
accept
![Page 20: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/20.jpg)
Accept–reject
sin21d
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
accept
21cossinaccept
21
21
021
21
021
d
P
![Page 21: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/21.jpg)
Accept–reject
2
slançamento
cortes
2accept
P
cortes
slançamento.2
![Page 22: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/22.jpg)
Accepted values
?accept P
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
![Page 23: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/23.jpg)
Accepted values
cos1accept21 P
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
![Page 24: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/24.jpg)
Accepted values
sinaccept21f
0
0.1
0.2
0.3
0.4
0.5
0 0.5 1 1.5 2 2.5 3
![Page 25: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/25.jpg)
U(0,) D U(0,½)
cos1accept
sinaccept
accept
2accept
sinD,accept
sinDaccept
21
0 21
0
sin
0
0
sin
0
2
2
21
21
21
21
P
duuP
dudvP
dudvP
PP
PP
u
u
![Page 26: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/26.jpg)
y = ½
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
0 0.5 1 1.5 2 2.5 3
accept
![Page 27: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/27.jpg)
y = 2.x.( - x)/
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
0 0.5 1 1.5 2 2.5 3
accept
![Page 28: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/28.jpg)
Accept–reject
032.2
021
0
2
021
32
2
2
cosaccept
.
sinaccept
P
d
dP
3accept P
ACEITA
MAIS
![Page 29: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/29.jpg)
y = 2.x.( - x)/2
yyyg
yyyg
dvvv
.
.
3.
3
2
2
6
3
2
0
2
yyyyG 023 3213
![Page 30: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/30.jpg)
G(y) = (3y2 – 2y3)/3
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0 0.5 1 1.5 2 2.5 3
![Page 31: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/31.jpg)
The Cubic formula
a
cr
a
adbcpq
a
bp
dcybyay
3
6
3
3
0
2
3
23
pprqqprqqy 3 3223 322
![Page 32: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/32.jpg)
Inverse Transformation
032
023
323
321
1
3
uyy
yyyu
yGu
uGy
1221221
2
3 23 2 uuuuuuy
![Page 33: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/33.jpg)
G D U(0,(/3).g())
0 21
0
sin
23
3
0 0
3
sin
23
sinaccept
3accept
,accept
sin
23
duuduugP
duugdvP
UPP
ug
u
g
ug
u
cos1accept21 P
sinaccept21DPP
![Page 34: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/34.jpg)
G D U(0,1)
0 21
0
sin
23
3
0 0
3
sin
23
sinaccept
3accept
,accept
sin
23
duuduugP
duugdvP
UPP
ug
u
g
ug
u
cos1accept21 P
gUPP
sin
23accept
![Page 35: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/35.jpg)
Acceptance – Rejection
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0.5
0 0.5 1 1.5 2 2.5 3
accept
y = g(x)
y = f(x)
![Page 36: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/36.jpg)
X G D U(0,1)
00
1
0 0
1
1
accept
accept
,accept
1
duufduugMxXP
duugdvMxXP
UxXPxXP
ug
uf
M
M
Xg
Xf
M
ug
uf
M
xFxXP accept
Xg
Xf
MUxXPxXP 1accept
![Page 37: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/37.jpg)
X G U U(0,1)
MM
xg
xf
M
Xg
Xf
M
dxxfP
dxxgP
dxxgxXUPP
11
1
1
accept
.accept
.accept
M
P 1accept
Xg
Xf
MUPP 1accept
![Page 38: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/38.jpg)
Acceptance – Rejection
while ( TRUE )
gerar X com distribuição G
gerar U uniforme em [0,1]
if U ≤ f(X)/M.g(X)
return (X)
Want to generate X with density f(x)
The proposal density g(x) is easier to generate
![Page 39: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/39.jpg)
X N(0,1)
0
0.2
0.4
0.6
0.8
1
1.2
1.4
-6 -4 -2 0 2 4 6
![Page 40: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/40.jpg)
X N(0,1)
0
0.2
0.4
0.6
0.8
1
1.2
1.4
-6 -4 -2 0 2 4 6
![Page 41: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/41.jpg)
M
212
21
2
21
2
21
2max2
2
2
max
max
eeM
eM
e
eM
xx
xx
x
x
eM 2
![Page 42: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/42.jpg)
X N(0,1)
0
0.2
0.4
0.6
0.8
1
1.2
1.4
-6 -4 -2 0 2 4 6
![Page 43: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/43.jpg)
X meia N(0,1)
0
0.2
0.4
0.6
0.8
1
1.2
1.4
-6 -4 -2 0 2 4 6
![Page 44: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/44.jpg)
Acceptance – Rejection
while ( TRUE )
gerar X com distribuição G
gerar U uniforme em [0,1]
if U ≤ f(X)/M.g(X)
return (X)
![Page 45: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/45.jpg)
f(x)/M.g(x)
212
21
2
21
.
. 2
2
xx
xe
x
exgM
xf
e
e
xgM
xf
221 1
.
xe
xgM
xf
![Page 46: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/46.jpg)
X meia N(0,1)
while ( TRUE )
gerar X com distribuição G
gerar U uniforme em [0,1]
if U ≤ e-0.5(X-1)²
return (X)
![Page 47: Monte Carlo - milidiu/inf2981/aulas/13_acceptance... A Agulha de Buffon Georges-Louis Leclerc – Conde de Buffon, 1777 Elementos uma agulha um piso Experimento Lançar a agulha ao](https://reader033.vdocuments.mx/reader033/viewer/2022052408/5c551aae93f3c32d68217aa8/html5/thumbnails/47.jpg)
X N(0,1)
while ( TRUE )
gerar X com distribuição exp(1)
gerar U uniforme em [0,1]
if U ≤ e-0.5(X-1)² break
gerar U uniforme em [0,1]
if U ≤ 0.5 then
return (X)
else return (–X)