English 中文(简体)
Python Normal Distribution
  • 时间:2024-12-22

Python - Normal Distribution


Previous Page Next Page  

The normal distribution is a form presenting data by arranging the probabipty distribution of each value in the data.Most values remain around the mean value making the arrangement symmetric.

We use various functions in numpy pbrary to mathematically calculate the values for a normal distribution. Histograms are created over which we plot the probabipty distribution curve.

import matplotpb.pyplot as plt
import numpy as np

mu, sigma = 0.5, 0.1
s = np.random.normal(mu, sigma, 1000)

# Create the bins and histogram
count, bins, ignored = plt.hist(s, 20, normed=True)

# Plot the distribution curve
plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) *
    np.exp( - (bins - mu)**2 / (2 * sigma**2) ),       pnewidth=3, color= y )
plt.show()

Its output is as follows −

normdist.png Advertisements