Sampling Gaussian distribution

Sampling Gaussian distribution

Any Gaussian distribution by stretching and translation can be obtained from the normal distribution, so here only consider the standard normal distribution

Inverse transformation

  • Generating \ ([0, 1] \) uniformly distributed random number in the \ (\ MU \)
  • Order \ (Z = \ ERF sqrt {2} ^ {-}. 1 (2 \ MU -. 1) \) , then \ (Z \) subject to the standard normal distribution. Where erf is the Gaussian error function, which is the standard normal cumulative distribution function of the form through the simple translation and pulled transformation, defined as
    \ [erf (x) = \ frac {2} {\ sqrt {\ pi}} \ int_0 ^ xe ^ {- t ^ 2} dt \]
  • erf not solve the inverse function

Box-Muller algorithm

  • Consider the joint distribution of two independent Gaussian distribution
  • Suppose \ (x, y \) is subject to two independent random variables standard normal
  • DETAILED sampling process is as follows:
    • Generating \ ([0, 1] \) uniformly distributed on two independent random numbers \ (\ mu_1, \ mu_2 \ )
    • Order \ (\ begin {cases} x = \ sqrt {-2 \ ln (\ mu_1)} \ cos2 \ pi \ mu_2 \\ y = \ sqrt {-2 \ ln (\ mu_1)} \ sin2 \ pi \ mu_2 \ Cases End {} \) , then \ (x, y \) subject to the standard normal distribution and are independent of each other
  • Need to calculate the trigonometric functions, time-consuming
  • Marsaglia polar method
    • Generating uniformly distributed random number in the unit of disk \ ((x, y) \ )
    • Order \ (S = Y ^ X ^ 2 + 2 \) , then \ (X \ sqrt {\ FRAC {-2 \ LN S} {S}} \) , \ (Y \ sqrt {\ FRAC {-2 \ ln s} {s}} \ ) is subject to two samples of the standard normal distribution

Refused sampling method

  • Selectivity index profile as a reference profile, takes \ (\ lambda = 1 \) exponential distribution, density function \ (q (x) = e ^ {- x} \)
  • Corresponding to the cumulative distribution function and its inverse function are
    \ [F. (X) =. 1 - E ^ {-} X \]
    \ [^ {F. -. 1} (\ MU) = - \ log (l- \ MU) \]
  • Using an inverse transform method is very easy to obtain sample index distribution, and then decide whether to accept the sample according to the refused sampling, the received probability
    \ [A (x) = \ frac {p (x)} {M \ cdot q (x)} \]
    wherein \ (p (x) = \ frac {2} {\ sqrt {2 \ pi}} e ^ {- \ frac {x ^ 2} {2}} \ (x \ geq 0) \) is the standard compressed to the normal probability density function of the positive axis, a constant factor \ (M \) need to meet the following conditions:
    \ [P (X) \ Leq M \ CDOT Q (X) \]
  • Was accepted probability calculation
    \ [A (x) = e ^ {- \ frac {(x-1) ^ 2} {2}} \]
  • DETAILED sampling process is as follows:
    • Generating \ (\ [0,1]) uniformly distributed on a random number \ (\ mu_0 \) , calculated \ (x = F ^ {- 1} (\ mu_0) \) to give sample index distribution \ (X \)
    • Regenerate \ (\ [0,1]) uniformly distributed on a random number \ (\ mu_1 \) , if the \ (\ mu_1 <A (X) \) , is accepted \ (X \) , or re-sampling
    • Regenerate \ (\ [0,1]) uniformly distributed on a random number \ (\ mu_2 \) , if the \ (\ mu_2 <0.5 \) , then \ (X \) is converted to \ (- X \) , otherwise remain unchanged
  • Ziggurat algorithm: The more steps to approximate rectangular target distribution, increase the probability of acceptance

Guess you like

Origin www.cnblogs.com/weilonghu/p/11922677.html