2020年5月16日土曜日

分布関数の形(単峰/双峰/多峰型)

講義で使える統計素材」シリーズ.今回は,確率(密度)分布関数の形「単峰型」「双峰型」「多峰型」の例を出しています.実際は全部正規分布の合成.

In [1]:
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as st

単峰型

In [2]:
sigma = 1.0
mu = 3.2

x = np.arange(0.0, 8.0, 0.01)
y = st.norm.pdf(x, 4.0, 1.0)
plt.figure(figsize=(4,4))
plt.ylim(0, 1)
plt.plot(x, y)
plt.fill_between( x, y )

plt.savefig('plot_out.svg')

双峰型

In [3]:
sigma = 1.0
mu = 3.2

x = np.arange(0.0, 8.0, 0.01)
y = (st.norm.pdf(x, 2.0, 1.0) + st.norm.pdf(x, 4.0, 0.5))/2.0
plt.figure(figsize=(4,4))
plt.ylim(0, 1)
plt.plot(x, y)
plt.fill_between( x, y )

plt.savefig('plot_out.svg')

多峰型

In [4]:
sigma = 1.0
mu = 3.2

x = np.arange(0.0, 8.0, 0.01)
y = (st.norm.pdf(x, 1.0, 1.0) + st.norm.pdf(x, 5.0, 0.5) + st.norm.pdf(x, 4.0, 0.2))/3.0
plt.figure(figsize=(4,4))
plt.ylim(0, 1)
plt.plot(x, y)
plt.fill_between( x, y )

plt.savefig('plot_out.svg')