• Monte Carlo Integration


    Monte Carlo Integration

    Monte Carlo integration uses a different perspective from Quadrature Integration to consider the problem of integration. Quadrature Integration from discrete to continuous, mainly uses the concept of limit convergence and continuous. Monte Carlo integral extended sampling and mathematical expectation of random variables.

    Probability Background

    Cumulative Distributions and Density Functions

    The cumulative distribution function, or CDF, of a random variable (X) is the probability that a value chosen from the variable’s distribution is less than or equal to some thresold (x):

    [cdf(X) = Pr{X leq x } ]

    The corresponding probability density function, or PDF, is the derivative of the CDF:

    [pdfleft( x ight) = frac{d}{d_x}cdfleft( x ight) ]

    and we can calculate the probility within an interval:

    [Prleft{ ale Xle b ight} = int_a^b{pdfleft( x ight) dx} ]

    Expected Values and Variance

    The expected value or expectation of a random variable (Y = f(x)) over a domain (mu(x)) is defined as:

    [Eleft[ Y ight] = int_{mu left( x ight)}{fleft( x ight) cdot pdfleft( x ight) dmu left( x ight)} ]

    while its variance is:

    [sigma ^2left[ Y ight] = Eleft[ left( Y-Eleft[ Y ight] ight) ^2 ight] ]

    The basic knowledge of probability statistics is this, and we will explain it when we use if have others

    TheMonte Carlo Estimator

    The Basic Estimator

    Monte Carlo integration uses random sampling of a function to numerically compute an estimate of its integral. Suppose that we want to integrate the one-dimensional function (f (x)) from (a) to (b):

    [F = int_a^b{fleft( x ight) dx} ]

    We can approximate this integral by averaging samples of the function (f) at uniform random points within the interval. Given a set of (N) uniform random variables (X_iin left[ a,b ight)) with a corresponding PDF of (1/(b-a)), theMonte Carlo estimator for computing (F) is:

    [leftlangle F^{N} ight angle=(b-a) frac{1}{N} sum_{i=0}^{N-1} fleft(X_{i} ight) ag{1} ]

    I think using an example directly, with (N=4) and interval ([a,b)), using uniformly distributed probability density, using random sampling can explain this formula very well.

    We use random sampling to get the value of random variable as shown above, as (f(X_0)), (f(X_1)), (f(X_2)), (f(X_3)).

    Then we use the following picture to simulate integration.

    But this integration process is a combination of sampling and statistical calculation of digital characteristics, which is Expected Values. This process is the process of formula (1). If we extend the number 4 to (N), we get the result of formula(1).

    Expected Value and Convergence

    Another question is, in the above question, how do we prove (leftlangle F^{N} ight angle = F = int_a^b{fleft( x ight) dx}) , wo first introducte a Theorem

    Law of Large Numbers

    Let (X_1, X_2, dots) be i.i.d(independent and identically distributed) with (E[X_i] = mu in R), (Var(X_i) = sigma^2 in (0, infty)) , if, (ar{X}_{n}=frac{1}{n} sum_{i=1}^{n} X_{i}) then, (ar{X}_{n} ightarrow mu) in (L^2) .

    we can get a result according to LLN :

    [operatorname{Pr}left{lim _{N ightarrow infty}leftlangle F^{N} ight angle=E[leftlangle F^{N} ight angle] ight}=1 ]

    and there is another problem is:

    [egin{aligned} Eleft[leftlangle F^{N} ight angle ight] &=Eleft[(b-a) frac{1}{N} sum_{i=0}^{N-1} fleft(X_{i} ight) ight] \ &=(b-a) frac{1}{N} sum_{i=0}^{N-1} Eleft[fleft(X_{i} ight) ight] \ &=(b-a) frac{1}{N} sum_{i=0}^{N-1} int_{a}^{b} f(x) p d f(x) d x \ &=frac{1}{N} sum_{i=0}^{N-1} int_{a}^{b} f(x) d x since pdf (x) = 1/(b -a) \ &=int_{a}^{b} f(x) d x \ &=F end{aligned} ag{2} ]

    Therefore,

    [operatorname{Pr}left{lim _{N ightarrow infty}leftlangle F^{N} ight angle=F ight}=1 ]

    Multidimensional Integration

    Monte Carlo integration can be generalized to use random variables drawn from arbitrary PDFs and to compute multidimensional integrals, such as:

    [F = int_{mu left( x ight)}{fleft( x ight) d mu left( x ight)} ]

    with the following modification to Equation (1):

    [leftlangle F^{N} ight angle= frac{1}{N} sum_{i=0}^{N-1} frac{fleft(X_{i} ight)}{pdf(X_i)} ag{3} ]

    It is similarly easy to show that this generalized estimator also has the correct expected value:

    [egin{aligned} Eleft[leftlangle F^{N} ight angle ight] &=Eleft[frac{1}{N} sum_{i=0}^{N-1} frac{fleft(X_{i} ight)}{operatorname{pdf}left(X_{i} ight)} ight] \ &=frac{1}{N} sum_{i=0}^{N-1} Eleft[frac{fleft(X_{i} ight)}{operatorname{pdf}left(X_{i} ight)} ight] \ &=frac{1}{N} sum_{i=0}^{N-1} int_{Omega} frac{f(x)}{p d f(x)} p d f(x) d x \ &=frac{1}{N} sum_{i=0}^{N-1} int_{Omega} f(x) d x \ &=int_{Omega} f(x) | d x \ &=F end{aligned} ]

    In addition to the convergence rate, a secondary benefit ofMonte Carlo integration over traditional numerical integration techniques is the ease of extending it to multiple dimensions. Deterministic quadrature techniques require using (N^d) samples for a d-dimensional integral. In contrast,Monte Carlo techniques provide the freedom of choosing any arbitrary number of samples. That means, we don't need to calculate every d-dimensional cube very clearly.

    Sources of Variance

    For the Variance of The Basic Estimator of Monte Carlo integration, Since the samples in Monte Carlo Method are independent, using Equation the variance of (leftlangle F^{N} ight angle) can be simplified to:

    [egin{aligned} sigma^{2}left[leftlangle F^{N} ight angle ight] &=sigma^{2}left[frac{1}{N} sum_{i=0}^{N-1} frac{fleft(X_{i} ight)}{p d fleft(X_{i} ight)} ight] \ &=frac{1}{N^{2}} sum_{i=0}^{N-1} sigma^{2}left[frac{fleft(X_{i} ight)}{p d fleft(X_{i} ight)} ight] \ &=frac{1}{N^{2}} sum_{i=0}^{N-1} sigma^{2}left[Y_{i} ight] \ &=frac{1}{N} sigma^{2}[Y] end{aligned} ag{4} ]

    and hence:

    [sigmaleft[leftlangle F^{N} ight angle ight]=frac{1}{sqrt{N}} sigma[Y] ag{5} ]

    where (Y_i = f(X_i) / pdf(X_i)) and (Y) represents the evaluation of any specific (Y_i) , This derivation proves that the standard deviation converges with (O(sqrt N)) . Moreover, this expression shows that by reducing the variance of each (Y_i) we can reducet he overall variance of (leftlangle F^{N} ight angle).

    Variance Reduction

    Earlier we calculated the variance of the Monte Carlo method to calculate the integral. This variance comes from the difference between the probability density function(PDF) that the sample conforms to and the integral function we seek. From the perspective of mathematical expectations, Monte Carlo integration can converge to traditional numerical integration, and the variance reflects the volatility of the sample. This means that if the sampling process is more similar to the integrand, the smaller the variance.

    Importance Sampling

    To demonstrate the effect of importance sampling, consider a PDF which is exactly proportional to the function being integrated, (pdf(x) = cf(x)) for some normalization constant (c). Since (c) is a constant, if we apply this PDF to theMonte Carlo estimator in Equation(3) , each sample (X_i) would have the same value.

    [Y_{i}=frac{fleft(X_{i} ight)}{p d fleft(X_{i} ight)}=frac{fleft(X_{i} ight)}{c fleft(X_{i} ight)}=frac{1}{c} ag{6} ]

    Since the PDF must integrate to one, it is easy to derive the value of (c):

    [c=frac{1}{int{fleft( x ight) dx}} ]

    However, (C) is actually what we want to know, so, This best case is therefore not a realistic situation.

    and we could use a figure to express the importance between the (pdf(x)) and (f(x))

    Comparison of three probability density functions. The PDF on the right provides variance reduction over the uniform PDF in the center. However, using the PDF on the left would significantly increase variance over simple uniform sampling. This is also easy to explain. For example, in the figure on the left, the probability of the distribution of (X_i) obtained by using the density function (pdf(x)) at both ends is greater than the probability of being distributed in the middle.

    Importance Sampling Complex Functions

    Most of the time, the integrand (f (x)) is very complicated, and we cannot guess its full behavior ahead of time. However, we may know something about its general structure. For instance, the integrand function (f (x)) may in fact be the combination of more than one function, e.g., (f(x) = g(x)h(x)) . In these situations, it may not be possible to create a PDF exactly proportional to (f (x)), but, if we know one of the functions in advance, we may be able to construct a PDF proportional to a portion of (f (x)), e.g., (pdf_g (x) propto g (x)). In this situation, the Monte Carlo estimator simplifies to:

    [egin{aligned} leftlangle F^{N} ight angle &=frac{1}{N} sum_{i=0}^{N-1} frac{fleft(X_{i} ight)}{p d f_{g}left(X_{i} ight)} \ &=frac{1}{N} sum_{i=0}^{N-1} frac{gleft(X_{i} ight) hleft(X_{i} ight)}{c gleft(X_{i} ight)} \ &=frac{1}{c N} sum_{i=0}^{N-1} hleft(X_{i} ight) end{aligned} ag{7} ]

    The above is a method to simplify the integration function (f). In addition, the operation of (f) can also be operated by polynomials, for example:Control variates is another variance-reduction technique which relies on some prior knowledge of the behavior of (f) . The idea behind control variates is to find a function g which can be analytically integrated and subtract it from the integral of (f):

    [egin{aligned} F &=int_{a}^{b} f(x) d x \ &=int_{a}^{b} f(x)-g(x) d x+int_{a}^{b} g(x) d x \ &=int_{a}^{b} f(x)-g(x) d x+G end{aligned} ag{8} ]

    We can then applyMonte Carlo integration to the modified integrand (f (x)-g (x)):

    [leftlangle F_{c}^{N} ight angle=left(frac{1}{N} sum_{i=0}^{N-1} frac{fleft(X_{i} ight)-gleft(X_{i} ight)}{p d fleft(X_{i} ight)} ight)+G \ = leftlangle F_{c}^{N} ight angle + G - leftlangle G^{N} ight angle ag{9} ]

    The ultimate goal of sampling in different ways is to make the variance of the Monte Carlo method small enough, In order to achieve this, we can operate in addition to the probability density function used for sampling, and also the sampling interval. Stratified Sampling is the principle used.

    Stratified Sampling

    Stratified sampling works by splitting up the original integral into a sum of integrals over sub-domains. In its simplest form, stratified sampling divides the domain ([a,b]) into (N) sub-domains (or interval) and places a random sample within each of these intervals. If using a uniform PDF, with (xi _iin left[ 0,1 ight)) , this can be expressed as:

    [egin{aligned} leftlangle F_{s}^{N} ight angle &=frac{(b-a)}{N} sum_{i=0}^{N-1} fleft(X_{i} ight) \ &=frac{(b-a)}{N} sum_{i=0}^{N-1} fleft(a+frac{i+xi_{i}}{N}(b-a) ight) \ &=frac{(b-a)}{N} sum_{i=0}^{N-1} fleft(a+xi_{i}^{N}(b-a) ight) end{aligned} ag{10} ]

    This method changes the sampling interval on the basis of the basic Monte Carlo method to make the sampling more uniform. The probability density function of the sampling used in each interval is still uniformly distributed.

    Most of the time, stratification can be added by simply replacing a canonical random number (xi _iin left[ 0,1 ight)) with a sequence of stratified random numbers in the same range (xi _{i}^{N}=frac{i+xi _i}{N}).

    Comparison to Deterministic Quadrature

    Stratified sampling incorporates ideas from deterministic quadrature, while still retaining the statistical properties ofMonte Carlo integration. It is informative to compare Equation 10 to a simple Riemann summation of the integral:

    [egin{aligned} F=int_{a}^{b} f(x) d x & approx sum_{i=0}^{N-1} fleft(x_{i} ight) Delta x \ & approx sum_{i=0}^{N-1} fleft(a+frac{i}{N}(b-a) ight) frac{(b-a)}{N} \ & approx frac{(b-a)}{N} sum_{i=0}^{N-1} fleft(a+frac{i}{N}(b-a) ight) end{aligned} ag{11} ]

    The Stratified samplingprocess can also be seen as Monte Carlo integration for each interval.

    Deterministic quadrature techniques such as a Riemann summation (left) sample the function at regular intervals. Conceptually, stratifiedMonte Carlo integration (right) performs a very similar summation, but instead evaluates the function at a random location within each of the strata.

  • 相关阅读:
    美国godaddy服务器,生成html网页出错,Microsoft VBScript runtime error '800a0005'
    Socket 错误一览表
    用php\asp创建 网页桌面快捷方式
    xp sp3 + ie8 支付宝证书 导入出错以及安全验证身份出错 解决办法
    Windows Server 2008正式版激活方法(2009年6月26日更新)
    子网掩码表示 255.255.255.0/24
    局域网中2台无线路由器联接配置方法
    firebug不能断点调试压缩后的js文件问题
    php正则匹配 <div></div>
    apache2 子目录forbidden问题
  • 原文地址:https://www.cnblogs.com/wevolf/p/13110971.html
Copyright © 2020-2023  润新知