正規分布・t分布・対数正規分布のグラフ
心理学データを確率モデルに基づいて分析するという観点から、上記3つの分布のグラフを描いて比較してみる。
正規分布は、統計学における標準的分布であり、心理学データ分析ではよく用いられている分布である。得られたデータの分布が、正規分布と比べて外れ値と見做されるものがあれば、それらは排除して分析される。採用するデータと排除するデータの区別を行わない方法として、正規分布より頑健なt分布による分析が説明されている(Gelman et al., 2014, p. 437)。
正規分布は、左右対称であるが、左右対称でない、右に分布の裾が伸びている分布として例えば対数正規分布がある。対数正規分布を用いた分析もよく行われている(Johnson et al., 1994, pp. 209-211, 238-240; JOGMEC, 2025;國仲ら、2011)。
上記3つの分布のグラフは図1のようである。
図1
平均値を50、標準偏差を20として描いたものであるが、比較のためt分布はパラメータを20と置いたものも示した。正規分布とt分布は平均値を軸として対称であるが、対数正規分布は裾が右の方に延びているのでモードが左側に寄っている。t分布は、パラメータ
が正規分布と同じ20であれば、正規分布を左右に延ばした形であるが、t分布の標準偏差を正規分布と同じ20に揃えると、平均値の方に集まった形である。図1の描画スクリプトは、リスト1に示した。
各分布について少し詳しく、以下の正規分布、t分布、対数正規分布の節において調べる。
正規分布はよく知られている分布であり、次式で与えられる。
正規分布は、心理学において最もよく用いられている分布である。パラメータ、
をもつ正規分布の平均値は
、標準偏差は
である。
平均値が40、60、80、標準偏差が10、20、30の正規分布のグラフを描くと、図2のようになる。
図2
平均値が大きくなると、グラフは右に移動している。標準偏差
が大きくなると、グラフは下に潰れていく。
図2のグラフは、リスト2のスクリプトで描いている。
t分布は、心理学ではデータの分布ではなく、統計的検定においてよく用いられ、次式で与えられる。
平均値はパラメータで与えられるが、分散は2つのパラメータ
と
により与えられている。パラメータ
は自由度と呼ばれることがある。
t分布のグラフを図3に示す。図3の描画スクリプトはリスト3に示すものである。
図3
パラメータと
に対するグラフの変化は正規分布の場合(図2)と同様である。パラメータ
が小さいと裾が厚くなるが、大きなると正規分布に近付く。
データが、正規分布から見て外れ値を含むと考えられるとき、t分布を用いると外れ値という特別な扱いをすることなく分析できる(Gelman et al., 2014)。心理学においても、t分布を用いる分析がもっと試みられてもよいと思われる。2つの独立なサンプルの平均値の分析をt分布を用いてベイズ分析を試みた例が、このウェブサイトにある。
対数正規分布は、広く用いられている確率分布であり(Johnson et al., 1994; JOGMEC, 2025;國仲ら、2011)、次式で与えられる。
すなわち、は、平均
、分散
の正規分布に従う。
対数正規分布に従うの平均値と分散は、次式で与えられる。
の平均値を
、標準偏差を
とおけば
であり、次式が成り立つ。
対数正規分布の平均値と標準偏差
の幾つかの組み合わせに対してグラフを描くと、図4のようになった。
図4
平均値を固定しても、標準偏差が異なると、グラフの山の部分(mode)が移動していることが分かる。心理学のデータ分析において、機械的に正規分布を用いるのではなく、データの分布(ヒストグラムなど)を検討して、裾が右側に延びているときは対数正規分布の利用を検討することが考えられる。
対数正規分布を用いた独立なサンプルの平均値のベイズ分析の例を、このウェブサイトに挙げておいた。
Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D> B., Vehtari, A, & Rubin, D. B. (2014). Bayesian data analysis, 3rd ed. CRC Press.
JOGMEC (2025.06ダウンロード),対数正規分布.https://oilgas-info.jogmec.go.jp/termlist/1001150/1001158.html
Johnson, N. L., Kotz, S., & Balakrishnan, N. (1994). Continuous univariate distributions, vol.1, 2nd ed. John Wiley & Sons, Inc.
國仲寛人・小林奈央樹・松下貢(2011) 複雑系にひそむ規則性一対数正規分布を軸にして一.日本物理学会誌、66、658ー665.
import scipy.stats as ss
import matplotlib.pyplot as plt
import numpy as np
def lognormal(x, mu, sgm):
v1 = sgm * x *
((2.0*np.pi)**0.5)
v2 = np.exp(-((np.log(x) -
mu)**2) / (2*(sgm**2)))
return v2 / v1
def mean_sd_to_t_mu_sgm(mean, sd, nu):
"""
mean and sd of a t-distribuion of degree nu
->
mu and sigma of the parameters
"""
return mean, ((sd**2)*(nu -
2)/nu)**0.5
def mean_sd_to_mu_sgm(mean, sd):
"""
mean and sd of a lognormal distribution
->
mu and sigma of the based normal distributon
"""
sgm_2 = np.log((sd**2) *
(mean**(-2)) + 1.0)
mu = np.log(mean) - (sgm_2 /
2.0)
return mu, sgm_2**0.5
L_normal_mean = 50.0
L_normal_sd = 20.0
df = 3
t_mu, t_sgm =
mean_sd_to_t_mu_sgm(L_normal_mean, L_normal_sd, df)
print('t_mu =', t_mu, ' t_sgm =',t_sgm)
L_normal_mu, L_normal_sgm =
mean_sd_to_mu_sgm(L_normal_mean, L_normal_sd)
print('L_normal_mu =', L_normal_mu,
' L_normal_sgm =',
L_normal_sgm)
x_coord = np.linspace(0.001, 100,
1000) # x > 0
y_normal = ss.norm.pdf(x_coord,
loc=50, scale=20)
y_t_distri = ss.t.pdf(x_coord, df,
loc=t_mu, scale=t_sgm)
y_t_sgm20 = ss.t.pdf(x_coord, df,
loc=t_mu, scale=20)
y_L_normal = lognormal(x_coord,
L_normal_mu, L_normal_sgm)
plt.plot(x_coord, y_normal,
label='normal')
plt.plot(x_coord, y_t_distri,
label='t')
plt.plot(x_coord, y_t_sgm20, ls='--',
label='t:sgm=20')
plt.plot(x_coord, y_L_normal,
label='lognormal')
plt.xticks(np.arange(0,100.1, 10))
plt.legend(fontsize=14)
plt.title('Mean = 50, SD = 20\n'+
f'sd of t_sgm20 = {((20**2*df/(df-2))**0.5):.2f}', fontsize=16)
plt.tight_layout()
plt.show()
import scipy.stats as ss
import matplotlib.pyplot as plt
import numpy as np
means = [40, 60, 80]
sds = [10, 20, 30]
colors = ['m', 'b', 'g']
lstyles = ['-', '--', '-.']
x_coord = np.arange(0, 100.1)
for i, mean in enumerate(means):
for j, sd in enumerate(sds):
print(mean, sd)
y_coord = ss.norm.pdf(x_coord, mean, sd)
plt.plot(x_coord, y_coord, c=colors[i], ls=lstyles[j],
label=f'mu={mean}, sd={sd}')
plt.legend()
plt.title('Normal distributions')
plt.show()
import scipy.stats as ss
import matplotlib.pyplot as plt
import numpy as np
def mean_sd_to_t_mu_sgm(mean, sd, nu):
"""
mean and sd of a t-distribuion of degree nu
->
mu and sigma of the parameters
"""
return mean, ((sd**2)*(nu -
2)/nu)**0.5
plt.figure(figsize=(15,6)) # グラフ全体のサイズ
plt.subplot(1,2,1)
# 左側のグラフの描画
means = [40, 60, 80]
sds = [10, 20, 30]
df = 3
colors = ['m', 'b', 'g']
lstyles = ['-', '--', '-.']
x_coord = np.arange(0, 100.1)
for i, mean in enumerate(means):
for j, sd in enumerate(sds):
mu,
sgm = mean_sd_to_t_mu_sgm(mean, sd, df)
# 自由度dfに対するmuとsgmの値
y_coord = ss.t.pdf(x_coord, df, mu, sgm)
plt.plot(x_coord, y_coord, c=colors[i], ls=lstyles[j],
label=fr'mu={mean}, sd={sd}')
plt.legend(fontsize=10)
plt.title('t-distributions',
fontsize=16)
plt.subplot(1,2,2) # 右側のグラフの描画
mu = 60
sgm = 20
dfs = [1,2,3,10]
for df in dfs:
y_coord = ss.t.pdf(x_coord,
df, mu, sgm)
plt.plot(x_coord, y_coord,
label=f'df={df}')
y_coord = ss.norm.pdf(x_coord, mu,
sgm)
plt.plot(x_coord, y_coord,
label='normal')
plt.legend(fontsize=16)
plt.title(fr'$\mu$=60, $\sigma$=20', fontsize=16)
plt.show()
import scipy.stats as ss
import matplotlib.pyplot as plt
import numpy as np
def lognormal(x, mu, sgm):
"""
対数正規分布の確率密度関数
"""
v1 = sgm * x *
((2.0*np.pi)**0.5)
v2 = np.exp(-((np.log(x) -
mu)**2) / (2*(sgm**2)))
return v2 / v1
def mean_sd_to_mu_sgm(mean, sd):
"""
mean and sd of a lognormal distribution
->
mu and sigma of the based normal
"""
sgm_2 = np.log((sd**2) *
(mean**(-2)) + 1.0)
mu = np.log(mean) - (sgm_2 /
2.0)
return mu, sgm_2**0.5
means = [40, 60, 80]
sds = [10, 20, 30]
df = 3
colors = ['m', 'b', 'g']
lstyles = ['-', '--', '-.']
x_coord = np.arange(0.001, 100.001,
0.01)
plt.figure(figsize=(10,5))
for i, mean in enumerate(means):
for j, sd in enumerate(sds):
mu,
sgm = mean_sd_to_mu_sgm(mean, sd)
y_coord = lognormal(x_coord, mu, sgm)
plt.plot(x_coord, y_coord, c=colors[i], ls=lstyles[j],
label=f'mn={mean}, sd={sd}')
plt.legend(bbox_to_anchor=(1.3,1))
plt.title('Lognormal distributions')
plt.tight_layout()
plt.show()