[Distribution family tree] The relationship between Gaussian distribution and inverse Gaussian distribution

Gaussian distribution

Normal distribution, also known as Gauss distribution, its probability density function is shown in the figure below

insert image description here
Normal distribution N ( μ , σ ) N(\mu, \sigma)N ( μ ,σ ) subject to expectationμ \muμ and varianceσ 2 \sigma^2p2 regulation, its probability density function is

1 2 π σ 2 exp ⁡ [ − ( x − μ ) 2 2 σ 2 ] \frac{1}{\sqrt{2\pi\sigma^2}}\exp[-\frac{(x-\mu) ^2}{2\sigma^2}]2 p.s _2 1exp[2 p2(xm )2]

μ = 0 \mu=0m=0 andσ = 1 \sigma=1p=When 1 , it is a standard normal distributionN ( 0 , 1 ) N(0,1)N(0,1 ) , the corresponding probability distribution function isΦ ( x ) = 1 2 π exp ⁡ [ − x 2 2 ] \Phi(x)=\frac{1}{\sqrt{2\pi}}\exp[-\frac {x^2}{2}]Φ ( x )=2 p.m 1exp[2x2]

Introduction to Inverse Gaussian Distribution

In Brownian motion, the Gaussian distribution describes the distribution of distance at a fixed moment; the inverse Gaussian distribution is the distribution of the time required to reach a fixed distance.

Therefore, the inverse of the inverse Gaussian distribution is taken from the physical meaning, rather than any "inverse" in the expression, and its PDF is

p ( x ) = λ 2 π x 3 exp ⁡ [ − λ ( x − μ ) 2 2 μ 2 x ] p(x)=\sqrt{\frac{\lambda}{2\pi x^3}}\ exp[-\frac{\lambda(x-\mu)^2}{2\mu^2x}]p(x)=2πx3l exp[2 m2x _λ ( xm )2]

scipy.statsfunction is provided in , invgaussbut its default λ = 1 \lambda=1l=1λ \lambdaWhen λ approaches infinity, the inverse Gaussian distribution tends to a Gaussian distribution.

In particular, when μ = λ = 1 \mu=\lambda=1m=l=1 , the inverse Gaussian distribution is also called the Wald distribution, and its probability density function expression is

p ( x ) = 1 2 π x 3 exp ⁡ [ − ( x − 1 ) 2 2 x ] p(x)=\frac{1}{\sqrt{2\pi x^3}}\exp[-\frac{(x-1)^2}{2x}] p(x)=2πx3 1exp[2x _(x1)2]

scipy.statswaldFunctions are also encapsulated in , ie wald.

Constructing an inverse Gaussian distribution from a Gaussian distribution

Random numbers of inverse Gaussian distribution can be generated through normal distribution and uniform distribution of random numbers, set ν \nuν obeys the standard normal distribution;zobeys the standard uniform distribution, then let

x = μ + μ 2 ν 2 2 λ − μ 2 λ 4 μ λ ν 2 + μ 2 ν 4 x=\mu+\frac{\mu^2\nu^2}{2\lambda}-\frac{\ mu}{2\lambda}\sqrt{4\mu\lambda\nu^2+\mu^2\nu^4}x=m+2 minm2 n22 minm4 m l n2+m2 n4

z ⩽ μ μ + x z\leqslant\frac{\mu}{\mu+x} zm + xm, then return xxx , otherwise returnμ 2 x \frac{\mu^2}{x}xm2

Considering invgaussthe default λ = 1 \lambda=1l=1 , soxxx的电视式改的x = μ + μ 2 ν 2 2 − μ 2 4 μ ν 2 + μ 2 ν 4 x=\mu+\frac{\mu^2\nu^2}{2}-\frac{ \mu}{2}\sqrt{4\mu\nu^2+\mu^2\nu^4}x=m+2m2 n22m4 m n2+m2 n4

import numpy as np
from scipy.stats import norm, invgauss, uniform
import matplotlib.pyplot as plt

nu = norm.rvs(size=10000)
mu = 1      # 设mu=1
n2, m2 = nu**2, mu**2
x = mu + m2*n2/2-mu/2*np.sqrt(4*mu*n2+m2*nu**4)

z = uniform.rvs(size=10000)
flag = z<(mu/(mu+x))

rs = flag*x + (1-flag)*m2/x


rv = invgauss(mu)
st, ed = rv.interval(0.995)
xs = np.linspace(st, ed, 200)

def drawPDF(rs, xs, ys):
    plt.figure(figsize=(5,3))
    plt.hist(rs, density=True, bins=100, alpha=0.8)
    plt.plot(xs, ys)
    plt.tight_layout()
    plt.show()

drawPDF(rs, xs, rv.pdf(xs))

The result is as follows

Guess you like

Origin blog.csdn.net/m0_37816922/article/details/130794253