95% 信頼区間の意味

2,000 社から 30 社を抽出する調査を 100 回。気候リスク認識スコア平均の 95% CI で外れたものを赤で表示。

95% 信頼区間の意味

「95% の信頼」は 1 本の区間ではなく手続きの性質です。ここでは 2,000 社の母集団が完全にわかっているので、その平均スコアが既知の真値になります。同じ小規模調査 — 無作為・非復元で抽出した 30 社 — を 100 回繰り返し、各横線は標本平均を中心とする 95% の t 区間です。そのうち約 95 本が真の平均(破線)を含み、外れた数本を赤で描いています。各標本が自らの標準偏差を推定するため、区間の幅もばらつきます。

設定は Kouloukoui, de Marcellis-Warin, Armellini, Warin & Andrade Torres (2021)(Journal of Cleaner Production)で、炭素集約型産業の企業が気候リスクへの曝露をどう認識しているかを扱います。認識スコア(0〜100、右に歪んだ分布)の母集団は説明のために numpy(シード固定)でシミュレーションしたもので、論文のデータや結果ではありません。区間は scipy.stats.t.interval によります。スコアが歪んでいるため、平均の低い標本はばらつきも小さくなりがちで、外れる区間は主に真の平均より下に現れます。また、100 回の調査を 1 セット行うと、偶然だけで 95% から数ポイント上下することがあります。

コードおよび図中のテキストは英語です。

confidence-intervals.py · 35 行
ダウンロード GitHub
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

# Simulated data, set in the context of Kouloukoui et al. (2021) [kouloukoui2021]
# Population: climate-risk perception scores (0–100) of 2,000 firms; 100 surveys of n = 30
rng = np.random.default_rng(2021)
score = 100 * rng.beta(2, 4.5, 2000)
mu, n, reps = score.mean(), 30, 100
samples = np.array([rng.choice(score, n, replace=False) for _ in range(reps)])
means = samples.mean(axis=1)
se = samples.std(axis=1, ddof=1) / np.sqrt(n)
lo, hi = stats.t.interval(0.95, df=n - 1, loc=means, scale=se)
miss = (lo > mu) | (hi < mu)

fig, ax = plt.subplots(figsize=(8, 6.6))
y = np.arange(1, reps + 1)
colors = np.where(miss, "#FF3B30", "#7FB8FF")
ax.hlines(y, lo, hi, color=colors, lw=np.where(miss, 2.2, 1.2))
ax.scatter(means, y, s=np.where(miss, 16, 9), color=colors, zorder=3, lw=0)
ax.vlines(mu, 0, reps + 1.5, color="#1D1D1F", ls="--", lw=1.2, zorder=4)
ax.text(mu, reps + 2.5, f"population mean score μ = {mu:.1f}", ha="center", va="bottom", fontsize=9.5,
        color="#1D1D1F")

ax.set_ylim(0, reps + 6)
ax.set_yticks([1, 25, 50, 75, 100])
ax.set_ylabel("Survey (random sample of firms)")
ax.set_xlabel("Mean climate-risk perception score with 95% CI (0–100)")
ax.grid(axis="y", visible=False); ax.grid(axis="x")
ax.margins(x=0.08)
ax.set_title(f"{reps - miss.sum()} of {reps} surveys' intervals capture the true mean score", pad=26)
ax.text(0, 1.02, f"Observed coverage {100 * (1 - miss.mean()):.0f}% (nominal 95%) · "
        f"each survey n = {n} of {len(score):,} firms (simulated) · t-intervals, {miss.sum()} misses in red",
        transform=ax.transAxes, fontsize=9.5, color="#6E6E73")
plt.show()

図にはオプションの PyStatlas スタイル を使用しています。同じ見た目にするには plt.style.use("pystatlas.mplstyle") を追加してください。

データの出典

  • Simulated data. Simulated data with a fixed random seed, created for this example.
    No real respondents, documents or measurements: the numbers only illustrate how the chart and its statistics work.
  • Kouloukoui et al. (2021), perceived exposure to climate risks. Kouloukoui, D., de Marcellis-Warin, N., Armellini, F., Warin, T., & Andrade Torres, E. (2021). Factors influencing the perception of exposure to climate risks: Evidence from the world's largest carbon-intensive industries. Journal of Cleaner Production, 306, 127160. https://doi.org/10.1016/j.jclepro.2021.127160
    The example is set in the context of this paper; unless its description says otherwise, the numbers are simulated and are not the paper's data or results.

これらの例は統計手法を説明するためのものです。項目に別の記載がない限り数値はシミュレーションであり、図のタイトルはこのシミュレーションデータで図が示す内容を述べたものです。引用した論文の知見でも、実質的な問いに対する著者の立場でもありません。結果、背景、データについては、ここに挙げた論文を参照してください。

引用方法

PyStatlas は Thierry Warin が作成・運営しています。研究や業務に役立った場合は、ぜひ引用してください。

Warin, T. (2026). What a 95% confidence interval means. In PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences (Version 1.1.0) [Computer software]. https://warin.ca/pystatlas/inference-uncertainty/confidence-intervals/

@misc{warin2026statlas,
  author       = {Warin, Thierry},
  title        = {PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences},
  year         = {2026},
  version      = {1.1.0},
  howpublished = {\url{https://warin.ca/pystatlas/}},
  note         = {Source code: https://github.com/warint/pystatlas}
}

推測と不確実性のその他のグラフ