0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

モンスターボールのサイズのばらつきはどこまで許せる?(正規分布入門)

Posted at

はじめに

モンスターボールのサイズが製品によって少しずつ違う…そんなことはありませんか?
この「ばらつき」がどれだけならOKで、どれだけ超えたらNGなのか。

本記事では、正規分布・t分布・カイ二乗分布といった統計分布を使って、モンスターボールのサイズばらつきを「確率的に」判断する方法を解説します。


1. 基本用語と定義(例付き)

用語 定義 モンスターボールの例
母集団(Population) 理論上考えられる全データ集合 世界中のすべてのモンスターボール(理想的な全数)
標本(Sample) 実際に観測・抽出された一部 ランダムに選んだ100個のボール
母平均(μ) 母集団の平均サイズ 直径 μ = 45.0 mm(設計値)
標本平均(x̄) 標本の平均サイズ x̄ = 45.1 mm(100個の平均)
母分散(σ²) 母集団サイズのばらつきの2乗平均 σ² = 0.04 mm²(標準偏差2mmの二乗)
標準偏差(σ) 1個あたりのばらつきの平均的な幅 σ = 2.0 mm(±2mmに約68%が収まる)

実際のサイズデータ(例)

No. 直径 (mm)
1 44.2
2 45.8
3 45.1
... ...
100 44.9

→ この100個の平均が x̄ = 45.1 mm、標準偏差が s = 2.0 mm と観測されたとします。


2. この「ばらつき」は大丈夫?:分布による解釈

正規分布(Normal Distribution)

  • 「測定値の多くは平均近辺にあり、離れるほど少なくなる」
  • 例:45.0 mm ± 2.0 mm → 約68%
  • ±4mm まで → 約95% → 実質の許容範囲

正規分布の式:

$$
f(x) = \frac{1}{\sqrt{2\pi}\sigma} e^{- \frac{(x - \mu)^2}{2\sigma^2}}
$$


標準化(Zスコア)で確率を求める

$$
Z = \frac{x̄ - \mu}{\sigma / \sqrt{n}} = \frac{45.1 - 45.0}{2.0 / \sqrt{100}} = \frac{0.1}{0.2} = 0.5
$$

→ このZスコア = 0.5 に対応する片側確率は約 0.6915
→ つまり、これくらいの差はよくある範囲


t分布(標本サイズが小さいとき)

  • n が小さい(例:n=10など)の場合、Zスコアの代わりに t値を使う
  • 平均の不確かさが大きいので、正規分布より裾が広い
  • n=100 であれば、ほぼ正規分布と同じ

カイ二乗分布(ばらつきの検定)

  • 「このばらつき(s²)は想定範囲内か?」
  • 母分散 σ² = 4.0 に対し、観測された s² = 4.4 のとき:

$$
\chi^2 = \frac{(n-1)s^2}{\sigma^2} = \frac{99 \cdot 4.4}{4.0} = 108.9
$$

→ カイ二乗分布(自由度99)の臨界値を超えていなければ、ばらつきも妥当と判断


3. 工業的解釈:このばらつきは許容範囲か?

  • 設計:直径45 ± 4 mm
  • → 合格ライン = [41, 49]
  • 正規分布においてこの範囲に収まる確率 ≒ 95.4%

不良率(= 規格外確率)

$$
P(x < 41 \text{ or } x > 49) ≈ 4.6%
$$

→ この4.6%は現実的か?→ 品質指数で判断


4. 品質指数(Cp, Cpk)

Cp(工程能力指数)

$$
Cp = \frac{USL - LSL}{6σ} = \frac{49 - 41}{6 \cdot 2.0} = \frac{8}{12} ≈ 0.67
$$

Cp < 1.0 は改善の余地あり!

Cpk(ズレ考慮)

$$
Cpk = \min\left(\frac{USL - \mu}{3σ}, \frac{\mu - LSL}{3σ}\right)
= \min\left(\frac{49 - 45.1}{6}, \frac{45.1 - 41}{6}\right)
= \min(0.65, 0.68) = 0.65
$$

→ 実際は中心がやや上にズレている


5. 積分=確率、そして「確率1」の意味とは?

確率密度関数(PDF)の曲線下の面積が「確率」です。正規分布の場合:

全体の面積は必ず 1(= 確率100%)

$$
\int_{-\infty}^{\infty} f(x) , dx = 1
$$

これは「すべてのモンスターボールはどこかのサイズを持っている」=サイズがどこかに必ずあることを意味します。

例:±2σ(45 ± 4mm)内に収まる確率は?

$$
P(41 \leq x \leq 49) = \int_{41}^{49} f(x), dx ≈ 0.954
$$

→ 面積 = 確率95.4%

逆に、±2σ外に出る確率(= 不良率)は?

$$
P(x < 41 \text{ or } x > 49) ≈ 1 - 0.954 = 0.046
$$


6. Pythonで正規分布と統計品質分析コード

# Program Name: pokeball_quality_check.py
# Creation Date: 20250601
# Overview: Evaluate Pokéball size variability using Normal, t, Chi-square distributions
# Usage: Execute all cells in Jupyter or Colab to visualize and evaluate quality metrics

# ライブラリのインストール
!pip install numpy scipy matplotlib

# ライブラリのインポート
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm, chi2

# ---------- 設定 / Parameters ----------
mu = 45.0             # 母平均(設計値)
sigma = 2.0           # 標準偏差
n = 100               # 標本サイズ
x_bar = 45.1          # 標本平均(観測値)
s2 = 4.4              # 標本分散(s²)
USL, LSL = 49, 41     # 規格上限・下限

# ---------- Zスコアと確率計算 ----------
se = sigma / np.sqrt(n)
z_score = (x_bar - mu) / se
p_value = 1 - norm.cdf(z_score)

# ---------- Cp, Cpk ----------
Cp = (USL - LSL) / (6 * sigma)
Cpk = min((USL - x_bar) / (3 * sigma), (x_bar - LSL) / (3 * sigma))

# ---------- 不良率 ----------
prob_within = norm.cdf(USL, mu, sigma) - norm.cdf(LSL, mu, sigma)
reject_rate = 1 - prob_within

# ---------- カイ二乗検定(ばらつき) ----------
df = n - 1
chi2_stat = df * s2 / sigma**2
chi2_p_right = 1 - chi2.cdf(chi2_stat, df)

# ---------- 結果出力 ----------
print(f"Zスコア: {z_score:.2f}")
print(f"片側確率(Z > {z_score:.2f}): {p_value:.4f}")
print(f"Cp: {Cp:.2f}")
print(f"Cpk: {Cpk:.2f}")
print(f"不良率: {reject_rate*100:.2f}%")
print(f"カイ二乗統計量: {chi2_stat:.2f}")
print(f"ばらつきが過剰な確率(右側P): {chi2_p_right:.4f}")

# ---------- 正規分布と不良領域の可視化 ----------
x = np.linspace(36, 54, 500)
y = norm.pdf(x, mu, sigma)

plt.figure(figsize=(10, 6))
plt.plot(x, y, label="Normal PDF")
plt.axvline(USL, color='red', linestyle='--', label='USL')
plt.axvline(LSL, color='blue', linestyle='--', label='LSL')
plt.axvline(x_bar, color='green', linestyle=':', label=f'Sample Mean: {x_bar}')
plt.fill_between(x, y, where=(x < LSL) | (x > USL), color='red', alpha=0.3, label='Reject Region')
plt.title("Pokéball Diameter Distribution with Spec Limits")
plt.xlabel("Diameter (mm)")
plt.ylabel("Density")
plt.legend()
plt.grid(True)
plt.show()

おわりに

このように、モンスターボールという身近な題材でも、統計学・品質管理・確率分布の本質的な考え方を直感的に学ぶことができます。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?