CS667 Lecture 6: Monte Crlo Integrtion 02/10/05 Venkt Krishnrj Lecturer: Steve Mrschner 1 Ide The min ide of Monte Crlo Integrtion is tht we cn estimte the vlue of n integrl by looking t lrge number of rndom points in the domin of tht integrl nd dding up the vlues. In generl, we find tht s we increse the number of rndom points, the ddition of those vlues converge towrds the integrl. To illustrte the bove ide, let us use simple exmple. As shown bove, suppose we hve region in the squre nd we only know how to find if prticulr point is in it or not. If we drop one million rndom points on the squre, nd count how mny fll inside tht, we will get n pproximte mesure of the re (re frction in relity). Similr exmple Telephone poll sking yes/no question to estimte number of people who own crs. For this poll to work, we need to know size of popultion correctly, nd more importntly, ensure tht there is uniform chnce t selecting ny given person (so tht our finl results reflect the overll popultion). The bove exmples re just counting or computing re (in other words, integrting function tht is one or zero). But we cn extend this principle to integrte complex integrls whose vlues cnnot be nlyticlly esily determined. For exmple, we try nd compute the verge height of given terrin. To perform this experiment, we drop 1 million sticky leflets from plne nd we mesure the ltitude where ech of those sticky leflets lnd (or of ech of those leflets itself). We cn see tht the verge height of the terrin will be verge height over ll those leflets (however, we need to ensure tht the leflets re thrown in such wy tht they re uniformly distributed nd tht they re sticky so tht they dont collect t low lying regions or vlleys to give incorrect results). Another exmple, Telephone survey to compute verge income in the United Sttes. To perform 1
this experiment, we could go bout sking every person in US their income nd verging their responses (which is quite tedious tsk, nd probbly not possible). However, insted, we could pick subset, like sking thousnd people nd verging their responses to estimte the verge income. However, we need to be creful of two things here. Agin, s we hve seen in the previous cse, we hve to ensure unform distribution (ie the subset is good indictor of the US popultion in generl) Also, we need to tke into ccount tht with phone survey, you will only get verge over those people who own phones (weighted by how mny phone numbers they hve.) Another issue, if you survey 100 people nd hppen to include one CEO in tht survey, then the results could be quite misleding. Sy we get 99 people with verge income t 50k, nd one CEO with slry of 5 million (100 times the verge), the men will be bout 100k, which is inccurte. With more typicl person insted of the CEO, we would hve got men of 50K. This is sometimes the reson s to why we my compute medins insted of mens when possible. In reltion to grphics, this mens tht we need to be creful while integrting distribution with outliers (for exmple, scene with mny norml light sources nd few very bright light source.) If we integrte in the presence of outliers, we will tend to get incorrect results. 2 Quick review of probbility 2.1 Discrete Rndom Vrible Definition: A vrible tht tkes on one of finite number of different vlues for every tril of n experiment is clled Discrete Rndom Vrible Eg Throw die, define rndom vrible X s number tht comes up. X hs equl probbility of tking on the vlues 1, 2...6 (the 6 outcomes hppen eqully frequently). The probbility spce R is set of vlues X cn tke on, nd the distribution of X ssigns frequency or probbility to ech. I ll cll these elements ω 1...ω 6 Exmple for the die The die cn tke ny discrete vlue between 1 to 6. We shll cll this set R. Also, ech of those fce vlues re eqully likely. Thus, mthemticlly, R {1, 2,...6} nd p(i) 1 6 for ech i which is n element of {1, 2...6} Here ω i i We write X p(i), where p is the probbility distribution for X 2.1.1 A few mthemticl definitions Expected Vlue or Men E{x} n i1 p(ω i)ω i 2
This is number you will get if you tke mny smples of x nd verge their vlues. Eg for the die E{x} 1 6 1 +... 1 6 6 21 6 3.5 If we tke bunch of smples nd verge them, then we get the smple men which is n estimte of the expected vlue If Xi p, for i 1 to N (they re smples of X), then 1 n n i1 x i is n estimte of E{X} Linerity of expecttion E{X + Y } E{X} + E{Y } Vrince σ 2 {X} E{X E{X}} 2 n i1 p(ω i)(ω i E{X}) 2 The vrince tells us something bout how spred out the distribution is A hndy formul : σ 2 {x} E{X 2 } E{X} 2 Proof : σ 2 {X} E{X E{X}} 2 E{X 2 2XE{X} + E{X} 2 } E{X 2 } 2E{XE{X}} + E{E{X} 2 } E{X 2 } E{X} 2 since E{XE{X}} E{X}E{X} nd E{E{X} 2 } E{X} 2 Eg Vrince of die E{x 2 } 1 6 + 1 6 22 + 1 6 32 +... + 1 6 62 91 6 Then, σ 2 {X} E{X 2 } E{X} 2 91 6 ( 21 6 )2 2 11 Alterntive wy of getting the result : E{(X E{X}) 2 } 1 6 (1 3 1 2 )2 + 1 6 (2 3 1 2 )2 +... + 1 6 (6 3 1 2 )2 2 11 Definition σ{x} σ 2 {X} Reltion between stndrd devition σ{x} nd vrince Another simple exmple Ω {0, 1}p(1) p, p(0) 1 p E{X} 1 p + 0 (1 p) p E{X 2 } 1.p + 0.(1 p) p E{X} 2 p 2 σ 2 {X} p p 2 p(1 p) 3
Note tht for p 0 or p 1, vrince is zero 2.2 Continuous Cse In this cse, Ω is n infinite set (eg the rel intervl [0,1]) nd then the rndom vrible X is clled continuous rndom vrible. In the continuous cse, the probbility is mesure: it ssigns finite probbility for ny finite(suitble) subset of R. But for well behved distributions, we cn tlk bout probbility density function, or pdf, p(x), where p(x) is the probbility of lnding ner x p(x)dx P r { < x < + dx} (or from dx 2 to + dx 2 ) P r {X S} S dp where ω dp 1 Here, expected vlue is n integrl insted of sum: E{X} Ω xp(x)dx or Ω xdp(x) The reltions for the discrete cse hold true, viz E{X + Y } E{X} + E{Y } σ 2 {X} Ω (x x)dp(x) Sme mnipultion s before shows σ 2 {X} E{X 2 } E{X} 2 Simple exmple for continuous probbility : Uniform distribution from to b p(x) 1 (b ) p(x) b b X 4
P r (x [, b ]) [,b ] dp 1 b dx (b ) (b ) E{X} 1 2 b + 2 xdp xp(x)dx x b dx b 2 2 b Now, we will compute the vrince σ 2 {X} E{X 2 } E{X} 2 1 3 x 2 dp ( b + 2 )2 x 2 p(x)dx ( b + 2 )2 x 2 + dx (b b 2 )2 b 3 3 b b2 + b + 2 3 (b + 2 )2 b2 + 2 + 2b 4 4b2 + 4b + 4 2 3b 2 3 2 6b b2 2b + 2 (b )2 3 Monte Crlo Integrtion Bsed on the fct tht the expected vlue of n rndom vrible is n integrl, we cn compute this integrl experimentlly. The bsic form, we wnt to compute I Ω f(x)dx 5
We wnt to do it using rndom smples generted ccording to distribution p. This mens we will tke smples x i p, evlute some function g(x i ) nd verge : I 1 N i g(x i) We sw erlier tht E{I} E{g(x)} Ω g(x)p(x)dx So, wht do you wnt for g? Clerly g(x) f(x) p(x) E{ f(x) p(x) } f(x) Ω p(x).p(x)dx Ω f(x)dx This is the core ide While coding, we need to thus tke cre of 2 importnt spects : Wht kind of probbility distribution we re using Wht is the function tht we re integrting As we cn see, our estimted vlue my not be the exct vlue of the integrl, however, before trying to express vrince quntittively, there re two methods to lower it Importnce Smpling Strtifiction In the next clss, we shll see the bove two techniques nd lso derive mthemticl expression for the vrince of I, nd how it is relted to the vrince of g. 6