All you need to know about Gaussian distribution
The distribution is fully described by the paramteres and , usually denoted as , where represents the expected value of the distribution and is the standard deviation.
The density is symmetrical across the expected value.
Main characteristic: Fluctuations around a central value.
For a higher-level description, see also: multivariate gaussian distribution.
Visualize: Open desmos and type normaldist(mu, var)
, to visualize a normal distribution with mean, variance, and cumulative probability.
Intuition
is exponential growth.
is exponential decay.
is exponential growth until , where there is a sharp point and it turns to exp. decay
smooths the entire function, which still decays in both directions (seen from the top), a bell curve.
the constant adjusts for wider / narrower bell curves. Can be rearranged to → not special.
Dividing by sigma and after squaring by allows us to specify the standard deviation.
Subtracting let’s us shift the distribution left and right.
After dividing by , the area under the curve equals .
We need to divide by one half sigma aswell to keep the area. Final result:If it is called the standard normal distribution.
Visually: 3b1b
Arises when many different independent variables are summed.
Affine property
Code
“From scratch”
import numpy as np
import matplotlib.pyplot as plt
mean = 0; std = 1; variance = np.square(std)
x = np.arange(-5,5,.01)
f = np.exp(-np.square(x-mean)/2*variance)/(np.sqrt(2*np.pi*variance))
plt.plot(x,f)
plt.ylabel('gaussian distribution')
plt.show()
With libs:
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import math
mu = 0
variance = 1
sigma = math.sqrt(variance)
x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100)
plt.plot(x, stats.norm.pdf(x, mu, sigma)) # probability density function
plt.show()