Python-data-science-python-normal-distribution

提供:Dev Guides
移動先:案内検索

Python-正規分布

正規分布は、データ内の各値の確率分布を配置することでデータを表示する形式です。ほとんどの値は平均値の周囲に残り、配置が対称になります。

numpyライブラリのさまざまな関数を使用して、正規分布の値を数学的に計算します。 確率分布曲線をプロットするヒストグラムが作成されます。

import matplotlib.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) ),       linewidth=3, color='y')
plt.show()

その*出力*は次のとおりです-

normdist.png