f(x)=\frac{1}{\sqrt{2\piσ^2}}e^{-\frac{(x-μ)^2}{2σ^2}}
The normal distribution is one of the typical distributions and is a frequent distribution in the field of statistics. However, the probability density function of the normal distribution is very complicated like the ↑ formula, and has buried many beginners. I also remember having a headache and dizziness when I first saw this formula when I started studying statistics.
In this article, the coefficient part ($ \ frac {1} {\ sqrt {2 \ piσ ^ 2}}
Many events in the world have the highest probability of taking an average value, and the probability of taking that value decreases as the distance from the average value increases.
An expression that simply expresses this is
f(x)=e^{-x^2}
is. In a graph,
import numpy as np
import matplotlib.pyplot as plt
def normal_dist(x, ave = 0, disp=1):
return np.exp((-(x-ave)**2)/(2*disp**2))
x = np.linspace(-3, 3)
y = normal_dist(x)
plt.plot(x,y)
plt.grid(axis="both")
plt.show()
It looks like a mountain.
This formula is inferior in versatility because only one graph can be drawn. Therefore, ① Move left and right of the graph ② Change the graph width Add the function of.
By changing the $ x $ part to $ x-μ $, you can shift the position of $ x $, which takes the maximum value.
f(x)=e^{-(x-μ)^2}
It becomes such a formula. Let's change the value of $ μ $ and see the change in the graph.
color = ["b", "g", "r", "c", "m"]
for i, col in enumerate(color):
y = normal_dist(x, i)
plt.plot(x, y, color=col)
plt.show()
The graph shifted to the right as $ μ $ increased.
You can change the width by multiplying the exponent part by $ \ frac {1} {2σ ^ 2} $.
f(x)=e^{-\frac{x^2}{2σ^2}}
x = np.linspace(-10, 10)
color = ["b", "g", "r", "c", "m"]
for i, col in enumerate(color):
y = normal_dist(x, 0, i+1)
plt.plot(x, y, color=col)
plt.show()
I succeeded in changing the width. The square of σ is to handle both positive and negative, and the multiplication of $ 2 $ is to make it easier to calculate.
Since it is a probability density function, the total area must be $ 1 $. So multiply the function by a convenient value. Put a convenient factor as $ c $ and
\int_{-\infty}^{\infty}ce^{-\frac{(x-μ)^2}{2σ^2}}dx=1
To calculate $ c $.
At first glance it may seem like a complicated calculation,
\int_{-\infty}^{\infty}e^{-ax^2}dx=\sqrt{\frac{\pi}{a}}
Using this Gaussian integral formula, if $ a = \ frac {1} {2σ ^ 2} $
c=\frac{1}{\sqrt{2\piσ^2}}
And it is easy to calculate. The solution is now the coefficient of the formula at the top.
After all, this formula was a formula that defines the probability density function by making $ f (x) = e ^ {-x ^ 2} $ versatile and adjusting the coefficients. I'm happy.
https://to-kei.net/distribution/normal-distribution/density-function-derivation/ Semantic understanding of the density function of the normal distribution
https://mathtrain.jp/gauss Two proofs of the Gaussian integral formula
https://bellcurve.jp/statistics/course/7797.html 14-1. Normal distribution
Recommended Posts