Monte-Carlo meetodid 4. loeng
description
Transcript of Monte-Carlo meetodid 4. loeng
![Page 1: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/1.jpg)
Monte-Carlo meetodid4. loeng
Lihtsa juhusliku suuruse genereerimine.
Juhuslike suuruste genereerimine jaotusfunktsiooni pööramise
meetodil.
![Page 2: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/2.jpg)
Lihtsa juhusliku suuruse (lõplik arv väärtuseid) genereerimine
P(Y=yi)=pi, i=1...k, 11
k
iip
Näide 1 (Bernoulli jaotus):
P(Y=“surm”) = 0,1
P(Y=“elus”) = 0,9
![Page 3: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/3.jpg)
Lihtsa juhusliku suuruse (lõplik arv väärtuseid) genereerimine
Sündide jaotus (2010)
Harju maakond 0,468
Hiiu maakond 0,006
Ida-Viru maakond 0,084
Jõgeva maakond 0,020
Järva maakond 0,024
Lääne maakond 0,015
Lääne-Viru maakond 0,044
Põlva maakond 0,019
Pärnu maakond 0,061
Rapla maakond 0,028
Saare maakond 0,022
Tartu maakond 0,132
Valga maakond 0,020
Viljandi maakond 0,033
Võru maakond 0,024
![Page 4: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/4.jpg)
Lihtsa juhusliku suuruse (lõplik arv väärtuseid) genereerimine
11 pDUP
0 1
Ui
p1p1 p2
P(“Mhmh”) = p1
P(“jaja”) = p2
U1
U1 Mhmh
U2
U2 Mhmh
U3
U3 jaja
D1D2
22 pDUP
![Page 5: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/5.jpg)
Lihtsa juhusliku suuruse (lõplik arv väärtuseid) genereerimine
1
1
i
jjp
0 1p1 p1+p2
i
jjp
1.... ....
p1 p2 pi
D1 D2 Di
Kui U sattub lõiku Di, siis genereeritakse
juhuslik suurus yi
![Page 6: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/6.jpg)
Binoomjaotuse modelleerimine
• Soovime genereerida X ~ B(1/4, 3)
0 1
“0” “1” “2” “3”
(1-1/4)3 (1-1/4)3+ 3(1-1/4)2(1/4)
1
0
)1(i
j
jjnjn ppC
![Page 7: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/7.jpg)
Jaotusfunktsiooni pööramise meetod
Jaotusfunktsioon
01
![Page 8: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/8.jpg)
Jaotusfunktsiooni pööramise meetod
Jaotusfunktsioon
01
x
F(x
)
![Page 9: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/9.jpg)
Jaotusfunktsiooni pööramise meetod
Jaotusfunktsiooni pöördfunktsioon
01
![Page 10: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/10.jpg)
Jaotusfunktsiooni pööramise meetod
Jaotusfunktsiooni pöördfunktsioon
01
y
F 1y
![Page 11: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/11.jpg)
Jaotusfunktsiooni pööramise meetod
10,y(x) kus ,)(1 yFxyF 10,)(:inf)(1 yyxFxyF
Jaotusfunktsiooni pöördfunktsioon
Jaotusfunktsiooni pöördfunktsioon
01
y
![Page 12: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/12.jpg)
10,)(:inf)(1 yyxFxyF
Jaotusfunktsiooni pööramise meetod
Jaotusfunktsiooni pöördfunktsioon
Jaotusfunktsiooni pöördfunktsioon
01
y
F 1y
![Page 13: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/13.jpg)
Jaotusfunktsiooni pööramise meetod
10,)(:inf)(1 yyxFxyF
Olgu U~U(0,1). Juhusliku suuruse F-1(U) jaotusfunktsiooniks on
)(
)()(1
xF
xFUPxUFP
![Page 14: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/14.jpg)
Näide. Eksponentjaotus.
00
0)(
x
xexf
x
x
dttfxF )()(
Eksponentjaotus parameetriga λ (EX= 1/λ):
Jaotusfunktsioon F(x)
01
00)(
xe
xxF x
![Page 15: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/15.jpg)
Jaotusfunktsiooni pööramine...
/)1ln()(
/)1ln(
)1ln(
1
1
1)(
1 yyF
yx
xy
ey
ey
exF
x
x
x
![Page 16: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/16.jpg)
Kasutamine
lambda=0.2
u=runif(10000)
X=-log(1-u)/lambda
hist(X)Genereeritud arvude histogramm
x
Sa
ge
du
s
0 10 20 30 40
01
00
02
00
03
00
04
00
0
![Page 17: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/17.jpg)
Kasutamine
lambda=0.2
u=runif(10000)
X=-log(1-u)/lambda
hist(X)Genereeritud arvude histogramm
x
Sa
ge
du
s
0 10 20 30 40
01
00
02
00
03
00
04
00
0
![Page 18: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/18.jpg)
Selgitav näide
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 19: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/19.jpg)
Selgitav näide
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 20: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/20.jpg)
Selgitav näide
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 21: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/21.jpg)
Selgitav näide
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 22: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/22.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 23: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/23.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 24: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/24.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 25: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/25.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 26: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/26.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 27: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/27.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
0 5 10 15 20 250
10
20
30
40
50
60
![Page 28: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/28.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
![Page 29: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/29.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
PU0.30.3
![Page 30: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/30.jpg)
0 5 10 15 20 25 30
0.0
0.2
0.4
0.6
0.8
1.0
x
F(x
)
PU0.30.3
PX 1.780.3FX1.780.3
1.78
![Page 31: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/31.jpg)
Ülesanne 1
f(x) = 2*x, kui 0<x<1, mujal 0
Kuidas genereerida antud jaotusest juhuslikke suuruseid?
![Page 32: Monte-Carlo meetodid 4. loeng](https://reader035.fdocument.pub/reader035/viewer/2022062222/56814b6c550346895db859f2/html5/thumbnails/32.jpg)
Ülesanne 2
F(x) = x3, kui 0<x<1
Kuidas genereerida antud jaotusest juhuslikke suuruseid?