[PYTHON] Generate a normal distribution with SciPy

The importance of the probability distribution is as previously emphasized, but the normal distribution is considered to be the most important distribution.

What is a normal distribution?

As you increase the distribution of the points you observe, a normal curve is drawn when the expected value and variance approach the following values.

E(X) → \mu \\
V(X) → \sigma^2

A distribution that uses this normal curve as a density function is called a ** normal distribution **.

The common representation of the normal distribution N (μ, σ ^ 2) is that the expected value is μ and the variance is σ ^ 2 (the square of the standard deviation).

Importance of normal distribution

As mentioned above, the normal distribution is the distribution that can be said to assume it most often.

First of all, there are a large number of natural and social phenomena that are thought to follow a normal distribution.

Also, I explained in the asymptotic theory, but when dealing with large numbers, the distribution is as close as possible to the normal distribution. If you have forgotten, let's remember the Central Limit Theorem again.

When the population follows a normal distribution, the sample function has a well-known major distribution.

What is a standard normal distribution table?

As I introduced earlier, the normal distribution N (0,1) with mean 0 variance 1 is called the standard normal distribution, and its mathematical table is called the normal distribution table. You can find any number of normal distribution tables by searching, but I always refer to the table below.

Standard normal distribution table http://www.koka.ac.jp/morigiwa/sjs/standard_normal_distribution.htm

Standard normal distribution table https://staff.aist.go.jp/t.ihara/normsdist.html

The equation of the normal curve (= probability density function of the normal distribution) can be written as follows.

y = \frac {1} {\sqrt{2\pi}\sigma}e^{-\frac {(x-\mu)^2} {2\sigma^2} }

Derivation of Z according to N (0,1) from this equation is called standardization.

X follows N (μ, σ ^ 2), and Z follows N (0,1).

Generate a normal distribution with SciPy

This has also appeared so far, but I will introduce it again.

from scipy.stats import norm

print( norm.mean(), norm.std(), norm.var() )
#=> (0.0, 1.0, 1.0)
#The mean of the normal distribution is 0, and the standard deviation and variance are 1.

#Randomly generate 10 variables that follow a normal distribution
r = norm.rvs(size=10)
print( r )
# => [-0.14257586  1.4193167  -1.74553227 -0.1446086  -0.84588791  0.6521945  0.38792576  1.12649729 -1.04827952  1.26594555]

#Since it is random, a value close to the mean 0 variance 1 is observed.
print( r.mean(), r.std(), r.var() )
# => (0.092499564763084963, 1.0138488700256538, 1.0278895312522951)

reference

Statistics (scipy.stats) http://docs.scipy.org/doc/scipy/reference/tutorial/stats.html

Recommended Posts

Generate a normal distribution with SciPy
Try drawing a normal distribution with matplotlib
3. Normal distribution with neural network!
Calculate sample distribution with Scipy (discrete distribution)
Generate a Pre-Signed URL with golang
[Python] Generate a password with Slackbot
Random number generator with normal distribution N (0,1)
LPC with Scipy
Bivariate normal distribution
ICA with Scipy
CORDIC with Scipy
Create a standard normal distribution graph in Python
What is a distribution?
A4 size with python-pptx
Generate a random sentence from your tweet with trigram
Steps to calculate the likelihood of a normal distribution
I tried to automatically generate a password with Python3
Create filter with scipy
[Python] Create a Tkinter program distribution file with cx_Freeze
Normarize data with Scipy
Decorate with a decorator
Verification of normal distribution
Use bubble sort to generate random numbers based on a standard normal distribution from uniform random numbers
Study math with Python: Draw a sympy (scipy) graph with matplotlib
Generate a password that is easy to remember with apg
Automatically generate frequency distribution table in one shot with Python
Learn librosa with a tutorial 1
Try programming with a shell!
Generate XML (RSS) with Python
Randomly generate a complete permutation
Create a homepage with django
Generate U distribution in Python
Using a printer with Debian 10
Make a fortune with Python
Create a heatmap with pyqtgraph
Use OpenBLAS with numpy, scipy
Create a directory with python
A little stuck with chainer
Draw a graph with networkx
Easily cProfile with a decorator
Extract peak values with scipy
Generate Pokemon with Deep Learning
Make a fire with kdeplot
Create a program that can generate your favorite images with Selenium
Define the reaction pattern with SMARTS with RDKit and generate a reactant
Generate physically sturdy shapes with GAN and print with a 3D printer