monte` carlo methods 1 monte` carlo methods integration and sampling techniques
DESCRIPTION
Monte` Carlo Methods3 PROBLEM STATEMENT System of equations and inequalities defines a region in m-spaceSystem of equations and inequalities defines a region in m-space Determine the volume of the regionDetermine the volume of the regionTRANSCRIPT
Monte` Carlo Methods 1
MONTE` CARLO METHODSMONTE` CARLO METHODS
INTEGRATION and SAMPLING INTEGRATION and SAMPLING TECHNIQUESTECHNIQUES
Monte` Carlo Methods 2
THE BOOK by THE BOOK by THE MANTHE MAN
Monte` Carlo Methods 3
PROBLEM STATEMENTPROBLEM STATEMENT
• System of equations and System of equations and inequalities defines a region in m-inequalities defines a region in m-spacespace
• Determine the volume of the Determine the volume of the regionregion
Monte` Carlo Methods 4
HISTORYHISTORY• 1919thth C. simple integral like E[X] using straight- C. simple integral like E[X] using straight-
forward samplingforward sampling• System of PDE solved using sample paths of System of PDE solved using sample paths of
Markov ChainsMarkov Chains– Rayleigh 1899Rayleigh 1899– Markov 1931Markov 1931
• Particles through a medium solved using Particles through a medium solved using Poisson Process and Random WalkPoisson Process and Random Walk– Manhattan ProjectManhattan Project
• Combinatorics in the ’80’s in RTP, NCCombinatorics in the ’80’s in RTP, NC
Monte` Carlo Methods 5
GROOMINGGROOMING
• R = volumetric regionR = volumetric region• R confined to [0,1]R confined to [0,1]mm
(R) = volume(R) = volume• Generalized area-under-the-curve Generalized area-under-the-curve
problemproblem
1
0
1
0
1
02121 ...),...,,(...)( mm dxdxdxxxxfR
Monte` Carlo Methods 6
ALGORITHMALGORITHM
• for i=1 to nfor i=1 to n– generate x in [0,1]generate x in [0,1]mm
– is x in R?is x in R?•S=S+1S=S+1
• endend(R)=S/n(R)=S/n
Monte` Carlo Methods 7
MESHMESH
• Generate x’s as a mesh of evenly Generate x’s as a mesh of evenly spaced pointsspaced points
• Each point is 1/k from its nearest Each point is 1/k from its nearest neighborneighbor
• n=kn=kmm
• Many varieties of this method, Many varieties of this method, generally called Multi-Gridgenerally called Multi-Grid
Monte` Carlo Methods 8
ERROR CONTROLERROR CONTROL
• Define a(R) = the surface Define a(R) = the surface area of Rarea of R
• a(R)/k = volume of a swath a(R)/k = volume of a swath around the surface 1/k thickaround the surface 1/k thick
• a(R)/k=a(R)/(na(R)/k=a(R)/(n1/m1/m) bounds ) bounds errorerror
Monte` Carlo Methods 9
...more ERROR CONTROL...more ERROR CONTROL
Monte` Carlo Methods 10
...more ERROR ...more ERROR • If we require error less than If we require error less than ......• the required sample n grows like xthe required sample n grows like xmm
nRanRa
m
m
)(
)(/1
Monte` Carlo Methods 11
PROBABLY NOT THAT BADPROBABLY NOT THAT BAD
• Reaction: the boundary of R isn’t Reaction: the boundary of R isn’t usually so-alignedusually so-aligned
• Probability statement on the Probability statement on the functions?functions?– this math exists but is only marginally this math exists but is only marginally
helpful with applied problemshelpful with applied problems
Monte` Carlo Methods 12
ALTERNATIVEALTERNATIVE• Monte` Carlo Method Monte` Carlo Method • for i = 1 to nfor i = 1 to n
– sample x from Uniform[0,1]sample x from Uniform[0,1]mm
– is x in R?is x in R?•S = S + 1S = S + 1
• end end hat = S/nhat = S/n
Monte` Carlo Methods 13
STATISTICAL TREATMENTSTATISTICAL TREATMENT• S is now a RANDOM VARIABLES is now a RANDOM VARIABLE• P[x in R] =P[x in R] =
– (volume of R)/(volume of unit hyper-cube)(volume of R)/(volume of unit hyper-cube)• S is a sum of Bernoulli TrialsS is a sum of Bernoulli Trials• S is Binomial(n, S is Binomial(n, ))• E[S] = E[S] = nn• VAR[S] = nVAR[S] = n (1- (1-))
Monte` Carlo Methods 14
ESTIMATORESTIMATOR
n
nSVARnSVAR
nSEnSE
)1(/][]/[
/][]/[2
Monte` Carlo Methods 15
CHEBYCHEV’S INEQUALITYCHEBYCHEV’S INEQUALITY
• Bounds Tails Bounds Tails of of DistributionsDistributions
• Z~F, E[Z]=0, Z~F, E[Z]=0, VAR[Z]= VAR[Z]= 22, , > 0> 0
2
2
2
2
2
1
ZP
ZP
ZP
Monte` Carlo Methods 16
• To get an error (statistical) To get an error (statistical) bounded by bounded by ......
2
2
)1(
/)1(
n
nnSP
Monte` Carlo Methods 17
SIMPLER BOUNDSSIMPLER BOUNDS (1-(1-) is bounded by ¼) is bounded by ¼• n = 1/(4n = 1/(422))• Does not depend on m!Does not depend on m!
Monte` Carlo Methods 18
SPREADSHEETSPREADSHEET• Find the volume of a sphere Find the volume of a sphere
centered at (0.5, 0.5, 0.5) with centered at (0.5, 0.5, 0.5) with radius 0.5 in [0,1]radius 0.5 in [0,1]33
• Chebyshev bounds look very loose Chebyshev bounds look very loose compared with VAR(compared with VAR(hat)hat)
• Use Use hat for hat for in the sample size in the sample size formulaformula
• Slow convergenceSlow convergence
Monte` Carlo Methods 19
STRATIFIED SAMPLINGSTRATIFIED SAMPLING
• Best of Mesh and Sampling Best of Mesh and Sampling MethodsMethods
• Very General application of Very General application of Variance ReductionVariance Reduction– survey samplingsurvey sampling– experimental designexperimental design– optimization via simulationoptimization via simulation
Monte` Carlo Methods 20
PARAMETERS AND DEFINITIONSPARAMETERS AND DEFINITIONS
• n = total number of sample pointsn = total number of sample points• Sample region [0,1]Sample region [0,1]mm is divided into r is divided into r
subregions Asubregions A11, A, A22, ..., A, ..., Arr
• ppii = P[x in A = P[x in Aii]]• k(x) = k(x) =
– 1 if x in R1 if x in R– 0 otherwise0 otherwise– so E[k(x)] = so E[k(x)] =
Monte` Carlo Methods 21
DENSITY OF SAMPLES xDENSITY OF SAMPLES x
• f(x) is the m-dim density function of f(x) is the m-dim density function of xx– for generalityfor generality– so we keep track of expectationsso we keep track of expectations– in our current scheme, f(x) = 1in our current scheme, f(x) = 1
Monte` Carlo Methods 22
LAMBDA AYELAMBDA AYE
]|)([
)()(
i
A ii
AxxkE
dxpxfxk
i
Monte` Carlo Methods 23
STRATIFICATIONSTRATIFICATION
• old method: generate x’s across old method: generate x’s across the whole regionthe whole region
• new method: generate the new method: generate the EXPECTED number of samples in EXPECTED number of samples in each subregioneach subregion
r
iii p
dxxfxkxkEm
1
]1,0[
)()()]([
Monte` Carlo Methods 24
• let Xlet Xjj be the jth sample in the old be the jth sample in the old methodmethod
n
Xkn
jj
1
)(̂
capitols indicate random samples!
Monte` Carlo Methods 25
VARIANCE OF THE ESTIMATORVARIANCE OF THE ESTIMATOR
dxXfXkn
dxXfXknVAR
n
Xk
jj
j
n
jj
n
jj
m
m
)(})({/1
)(})({)/1()ˆ(
)(ˆ
2
]1,0[
2
1 ]1,0[
2
1
Monte` Carlo Methods 26
STRATIFICATION STRATIFICATION
• Generate nGenerate n11, n, n22, ..., n, ..., nrr samples from samples from AA11, A, A22, ..., A, ..., Arr
– on purposeon purpose• nnii = np = npii
• nnii sum to n sum to n• XXi,ji,j is jth sample from A is jth sample from Aii
Monte` Carlo Methods 27
ii is a conditional expectation is a conditional expectation
21,
2
,
])([
)]([
iii
iji
XkE
XkE
Monte` Carlo Methods 28
i
r
i
n
jjiiSTRAT nXkp
i
/)(1 1
,
Monte` Carlo Methods 29
r
i Ajijiiji
r
i Aji
i
jiijii
i
i
r
i
n
jji
i
iSTRAT
i
i
i
XdXfXkn
XdpXf
Xknpnpp
XkVARnpVAR
1,,
2,
1,
,2,22
2
1 1,2
2
)()()(1
)()(
)(
))(()(
Monte` Carlo Methods 30
r
iii
r
i Ajijiiji
r
i AjijiijiSTRAT
pnVAR
XdXfXkn
XdXfXkn
VAR
i
i
1
2
1,,
2,
1,,
2,
)()/1()ˆ(
)()()(1
)()()(1)(
Monte` Carlo Methods 31
HOW THAT LAST BIT WORKEDHOW THAT LAST BIT WORKED
22,
2,
2,
2,
][])([
][))()((2])([
)]()([
iji
iijiji
iji
XkE
XkEXkE
XkE
Monte` Carlo Methods 32
...AND SO......AND SO...• Stratification reduces the variance Stratification reduces the variance
of the estimatorof the estimator• A random quantity (the samples A random quantity (the samples
pulled from Apulled from Aii) is replaced by its ) is replaced by its expectationexpectation
• This only works because of all of This only works because of all of the SUMMATION and no other the SUMMATION and no other complicated functionscomplicated functions
Monte` Carlo Methods 33
FOR THE SPHERE PROBLEMFOR THE SPHERE PROBLEM• 500 samples500 samples
– Divide evenly in 64 cubesDivide evenly in 64 cubes• 4 X 4 X 44 X 4 X 4• 7 or 8 samples in each cube7 or 8 samples in each cube
– 64 separate 64 separate ’s’s– Add togetherAdd together
• How did we know to start with 500?How did we know to start with 500?
Monte` Carlo Methods 34
Discussion of applications...Discussion of applications...