SlideShare a Scribd company logo
1 of 23
統計学
・事象と確率
𝑃 𝐴 ∪ 𝐵 = 𝑃 𝐴 + 𝑃 𝐵 − 𝑃(𝐴 ∩ 𝐵)
P(A):事象Aの確率
P(B):事象Bの確率
P(Ac):Aの余事象(Aが起こらないこと)の確率
A ∩ B
A B
Ω
Venn diagram
包除原理
問
ある50名のクラスで、前日にテレビ番組Aを見た生徒は
20名、番組Bを見た生徒は15であった。また両方を見た
生徒は5名であった。どちらの番組も見なかった生徒は何
名か。(答え:20人)
条件付確率とベイズの定理(結果から原因の確立を求める)
2つの事象の間の関係を考える操作が条件付き確率の計算
𝑃 𝐵 𝐴 =
𝑃(𝐴 ∩ 𝐵)
𝑃(𝐴)
→ P A ∩ 𝐵 = 𝑃 𝐴 × 𝑃(𝐵|𝐴)
P(B|A):Aが起きたという条件のもとでBが起きる条件付き確率
P(B) = P(B|A)ならばAとBは独立
P A B =
𝑃 𝐵 𝐴 𝑃(𝐴)
𝑃(𝐵)
=
𝑃 𝐵 𝐴 𝑃(𝐴)
𝑃 𝐵 𝐴 𝑃 𝐴 + 𝑃 𝐵 𝐴𝑐 (𝐴𝑐)
↑ベイズの定理
P(A)をAの事前確率といい、P(A|B)を事後確率という
𝑃 𝐴𝑖 B =
𝑃 𝐵 𝐴𝑖 𝑃(𝐴𝑖)
𝑗=1
𝑘
𝑃 𝐵 𝐴𝑗 𝑃(𝐴𝑗)
特定の要因
すべての要因
期待値と分散(離散的な確率変数)
確率変数:ランダムに変動する変数のこと(X)
確率関数:Xが値xをとる確率P(X=x)をp(x)と表す
xの期待値 𝜇 = 𝐸 𝑋 =
𝑥
𝑥𝑝(𝑥)
𝜇 = 𝐸 𝑔(𝑥) =
𝑥
𝑔 𝑥 𝑝(𝑥)
Xの関数g(x)の期待値
分散 𝜎2 = 𝑉 𝑋 = 𝐸[ 𝑋 − 𝜇 ²] =
𝑥
𝑥 − 𝜇 2𝑝(𝑥)
※ 𝑥 は取りうるすべての値xに関する和
※分散の導出
確率密度関数(連続的な確率変数)
確率密度関数(probability density function f(x))
𝑓 𝑥 = lim
𝜀→0
𝑃(𝑥 < 𝑋 ≤ 𝑥 + 𝜀)
𝜖
𝐸 𝑋 =
−∞
∞
𝑥𝑓 𝑥 𝑑𝑥
𝑉 𝑋 =
−∞
∞
𝑥 − 𝜇 2𝑓 𝑥 𝑑𝑥 𝑎
𝑏
𝑓 𝑥 𝑑𝑥 = 1
x
a b
累積分布関数と生存関数
関数グラフ
累積分布関数
𝐹 𝑥 =
𝑥′≤𝑥
𝑝(𝑥′)
𝐹 𝑥 =
−∞
𝑥
𝑓(𝑥′)
離散型
連続型 ※微積分の関係
生存関数:S(x) = 1 – F(x)
確率変数Xが寿命を表す場合、F(x)は時刻x時点で死亡
する確率。
生存関数は時刻x時点でまだ生きている確率を表す。
※ハザード関数:h(x) = f(x)/1-F(x) = (-logS(x))’
ハザード関数は時刻xにおいて生きている者の内、
その後短時間で死亡する者の率を表す。
生存関数の例:
・疾病の再発または回復までの時間
・品質管理の分野では工業製品が故障するまでの時間
・経済の分野では失業期間
※生存関数の理解
• まだ
同時確率密度関数~変数の拡張~
p(x,y) = P(X=x, Y=y):Xが値xをとり、Yが値yをとる確率
離散型→同時確率関数
𝐹 𝑥, 𝑦 = 𝑃 𝑋 ≤ 𝑥, 𝑌 ≤ 𝑦 =
𝑥′≤𝑥,𝑦′≤𝑦
𝑝(𝑥′, 𝑦′)
𝑝𝑋(𝑥) =
𝑦
𝑝(𝑥 , 𝑦 )
周辺確率関数
𝑝𝑌|𝑋 𝑦 𝑥 =
𝑝(𝑥, 𝑦)
𝑝𝑋(𝑥)
条件付き確率関数
連続型→同時確率密度関数
𝑓(𝑥, 𝑦) =
𝜕2
𝜕𝑥𝜕𝑦
𝐹(𝑥, 𝑦)
累積分布関数
𝑃 𝑥1 ≤ 𝑋 ≤ 𝑥2, 𝑦1 ≤ 𝑌 ≤ 𝑦2 =
𝑥1
𝑥2
𝑦1
𝑦2
𝑓(𝑥, 𝑦)𝑑𝑥𝑑𝑦
𝑓𝑋(𝑥) =
−∞
∞
𝑓 𝑥, 𝑦 𝑑𝑦
周辺確率関数
𝑝𝑌|𝑋 𝑦 𝑥 =
𝑝(𝑥, 𝑦)
𝑝𝑋(𝑥)
条件付き確率密度関数
n個の連続確率変数も同様に拡張できる。
条件付き独立??
※同時確率関数のイメージ(2次元の正規分布)
#python3
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import scipy.stats as st
from scipy.stats import multivariate_normal
from mpl_toolkits.mplot3d import Axes3D
#データの設定
x, y = np.mgrid[10:100:2, 10:100:2]
pos=np.empty(x.shape + (2, ))
pos[:, :, 0] = x
pos[:, :, 1] = y
#多次元正規分布
#それぞれの変数の平均と無難共分散行列を設定
#以下の例では、x,yの平均がそれぞれ、50,
rv = multivariate_normal([50,50], [[100,0],[0,100]])
z = rv.pdf(pos)
fig = plt.figure(dpi=100)
ax = Axes3D(fig)
ax.plot_wireframe(x, y, z)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("f(x, y)")
ax.ticklabel_format(style="sci", axis="z", scilimits=(0,0))
母関数(モーメント母関数・確率母関数)
確率母関数 𝐺 𝑠 = 𝐸 𝑠𝑋
=
𝑥
𝑠𝑥𝑝(𝑥)
右辺が収束を仮定
𝐺′
1 = 𝐸 𝑋 , 𝐺′′
1 = E[𝑋(𝑋 − 1)]
ここから、Xの期待値と分散を示すことができる
モーメント母関数:s=eθとする
m 𝜃 = 𝐸 𝑒𝜃𝑋
= 𝐺(𝑒𝜃)
m′ 0
= 𝐸 𝑋 , 𝑚′′
0 = 𝐸 𝑋2 , 𝑚
𝑘
0 = 𝐸[𝑋𝑘]
特徴:
(1)確率分布との1対1対応
(2)独立な変数の和が母関数の積に対応
𝑋1 + ⋯ 𝑋𝑛のモーメント母関数mn(θ)はmn(θ)=mn(θ)n
※特性関数:θ=it(準虚数を代入)
確率変数の分布の特性値➀
• 期待値
• 中央値(median)
• 最頻値(mode)
• 四分位範囲:第3四分位数-第1四分位数
• 標準偏差: 𝑉[𝑋]
• 変動係数(散らばりの指標): 𝑉[𝑋] 𝐸[𝑋]
期待値
中央値
最頻値
中央値
最頻値
期待値
Xの確率密度関数をf(x)とするとき、
中央値:P(x<= a) = 0.5となるa
最頻値:f(x)が最大となるx
として定義される。
☐分位点関数…
確率変数の分布の特性値➁
• 歪度:分布の歪みの指標
• 尖度:標準化した分布の裾の重さの指標
歪度
尖度
𝐸[(𝑋 − 𝐸 𝑋 )3]
(𝑉[𝑋])3/2
𝐸[(𝑋 − 𝐸 𝑋 )4
]
(𝑉[𝑋])2
歪度:√2
尖度:3
歪度:0
尖度:6
同時分布の特性値(共分散・相関係数)
• 相関:2つの確率変数XとYの関係を表す概念。
𝐶𝑜𝑣 𝑋, 𝑌 = 𝐸 𝑋 − 𝐸 𝑋 𝑌 − 𝐸 𝑌 = 𝐸 𝑋𝑌 − 𝐸 𝑋 𝐸[𝑌]
他の確率変数と比較するために、基準化したい、、、
→標準化(平均0,標準偏差1)して、共分散を計算する
𝜌[𝑋, 𝑌] = 𝐸
𝑋 − 𝐸[𝑋]
𝑉[𝑋]
𝑌 − 𝐸[𝑌]
𝑉[𝑌]
=
𝐶𝑜𝑣[𝑋, 𝑌]
𝑉 𝑋 𝑉[𝑌]
相関係数
共分散
同時分布の特性値(偏相関係数・条件付き期待値・分散)
偏相関係数
Zの影響を除いた、XとYの偏相関係数
𝜌 𝑋, 𝑌|𝑍 =
𝜌 𝑋, 𝑌 − 𝜌[𝑋, 𝑍]𝜌[𝑌, 𝑍]
(1 − 𝜌 𝑋, 𝑍 2)(1 − 𝜌[𝑌, 𝑍]2)
条件付き期待値・分散
Xが与えられた下でのYの条件付き期待値・分散
𝐸 𝑌 𝑋 =
−∞
∞
𝑦𝑓𝑌|𝑋 𝑦 𝑑𝑦 𝑉 𝑌 𝑋 = 𝐸 𝑌2 𝑋 − 𝐸 𝑌 𝑋 2
特性値の性質(期待値・分散の計算方法)
• 確率変数X, Yと定数a, b, cについて、以下の式が成り立つ。
期待値
𝐸 𝑎𝑋 + 𝑏𝑌 + 𝑐 = 𝑎𝐸 𝑋 + 𝑏𝐸 𝑌 + 𝑐
が成り立つ。また、XとYが独立であれば、
𝐸 𝑋𝑌 = 𝐸 𝑋 𝐸[𝑌]
分散
𝑉 𝑎𝑋 + 𝑏 = 𝑎2𝑉 𝑋 , 𝑉 𝑋 ± 𝑌 = 𝑉 𝑋 + 𝑉 𝑌 ± 2𝐶𝑜𝑣 𝑋, 𝑌
独立であれば、
𝑉 𝑋 + 𝑌 = 𝑉 𝑋 + 𝑉[𝑌]
条件付き期待値
𝐸 E[X|Y ] = 𝐸 𝑋
が成り立つ。また、分散については
𝑉 𝑋 = 𝐸[𝑉 𝑋 𝑌 + 𝑉[𝐸 𝑋 𝑌 ]
※証明つける
データの特性値
加重平均
幾何平均 調和平均
算術平均
これまでは分布の特性値。今回は実際に観測されたデータに対する特性値。
𝑥 =
1
𝑛 𝑖=1
𝑛
𝑥𝑖 𝑥 =
𝑖=1
𝑛
𝑤𝑖𝑥𝑖
割合wiで得られる場合の全平均
𝑥 =
𝑖
𝑛
𝑥𝑖
1/𝑛
𝑥 =
1
𝑛 𝑖=1
𝑛 1
𝑥𝑖
調和平均は割合の平均を意味している。
幾何平均のn乗が一致する
平均ベクトルと分散共分散行列
• 平均ベクトル:𝜇 = 𝜇1, 𝜇2 … 𝜇k T
• 分散共分散行列:𝑋𝑖, 𝑋𝑗の共分散𝜎𝑖𝑗を(I,j)要素とする行列
=
𝜎11 ⋯ 𝜎1𝑗
⋮ ⋱ ⋮
𝜎𝑖1 ⋯ 𝜎𝑖𝑗
𝑆 =
1
𝑛 − 1 𝑖=1
𝑛
𝑥𝑖 − 𝑥 𝑥𝑖 − 𝑥 𝑇
2
2 10
10
2×10 10×2 2×2
※サンプリングによる確率分布(正規分布)の直観的理解
大数の法則:n数の上昇につれて、母集団は正規分布に近似できるようになる。
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
np.random.seed(100)
plt.subplot(221)
a = norm.rvs(size=500)
plt.hist(a,100)
plt.subplot(222)
b= norm.rvs(size=5000)
plt.hist(b,100)
plt.subplot(223)
c = norm.rvs(size=50000)
plt.hist(c,100)
plt.subplot(224)
d = norm.rvs(size=500000)
plt.hist(d,100)
plt.show()
※正規分布(Normal Distribution)
#python3
import matplotlib.pyplot as plt
from scipy.stats import norm
x = np.arange(-5,5,0.1)
y = norm.pdf(x)
plt.plot(x,y,color="green")
plt.show()
身長・体重
𝑓 𝑥 =
1
2𝜋𝜎2
exp(−
(𝑥 − 𝜇)2
2𝜎2 )
𝑓 𝑥 =
1
2𝜋
exp(−
𝑥2
2
)
標準化(平均0, 標準偏差1)↓
※ポアソン分布(Poisson Distribution)
• 自動車事故件数
• 台風の件数
#python3
import matplotlib.pyplot as plt
from scipy.stats import poisson
x = np.arange(0,20,1)
rv = poisson(5)
y = rv.pmf(x)
plt.plot(x,y,color="red")
plt.show()
𝑓 𝑥 =
𝜇𝑥
exp(−𝜇)
𝑥!
, 𝑥 = 0,1,2,3. .
x:イベント発生数
𝜇:平均発生数
更新履歴
• 5/28,29:スライド製作(統計学ワーク1~3章)
参考書籍
• 統計学実践ワークブック(日本統計学会 編)
• データサイエンティスト育成講座(マイナビ)
• NumPy & SciPy数値計算実装ハンドブック(秀和システム)

More Related Content

What's hot

IB Maths.Turning points. Second derivative test
IB Maths.Turning points. Second derivative testIB Maths.Turning points. Second derivative test
IB Maths.Turning points. Second derivative test
estelav
 
Statistik 1 5 distribusi probabilitas diskrit
Statistik 1 5 distribusi probabilitas diskritStatistik 1 5 distribusi probabilitas diskrit
Statistik 1 5 distribusi probabilitas diskrit
Selvin Hadi
 
The mc nemar test for significance of changes
The mc nemar test for significance of changesThe mc nemar test for significance of changes
The mc nemar test for significance of changes
Zuhdha Basofi Nugroho
 
Limits richard
Limits richardLimits richard
Limits richard
canalculus
 

What's hot (19)

Statistics lecture 6 (ch5)
Statistics lecture 6 (ch5)Statistics lecture 6 (ch5)
Statistics lecture 6 (ch5)
 
Lecture 7(b) derivative as a function
Lecture 7(b)   derivative as a functionLecture 7(b)   derivative as a function
Lecture 7(b) derivative as a function
 
__limite functions.sect22-24
  __limite functions.sect22-24  __limite functions.sect22-24
__limite functions.sect22-24
 
Chapter 1 random variables and probability distributions
Chapter 1   random variables and probability distributionsChapter 1   random variables and probability distributions
Chapter 1 random variables and probability distributions
 
Qam formulas
Qam formulasQam formulas
Qam formulas
 
Random variable
Random variable Random variable
Random variable
 
IB Maths.Turning points. Second derivative test
IB Maths.Turning points. Second derivative testIB Maths.Turning points. Second derivative test
IB Maths.Turning points. Second derivative test
 
ppt of Calculus
ppt of Calculusppt of Calculus
ppt of Calculus
 
Probability Distribution
Probability DistributionProbability Distribution
Probability Distribution
 
Introduction to Discrete Random Variables
Introduction to Discrete Random VariablesIntroduction to Discrete Random Variables
Introduction to Discrete Random Variables
 
Statistik 1 5 distribusi probabilitas diskrit
Statistik 1 5 distribusi probabilitas diskritStatistik 1 5 distribusi probabilitas diskrit
Statistik 1 5 distribusi probabilitas diskrit
 
The mc nemar test for significance of changes
The mc nemar test for significance of changesThe mc nemar test for significance of changes
The mc nemar test for significance of changes
 
Random variable
Random variableRandom variable
Random variable
 
Secant Iterative method
Secant Iterative methodSecant Iterative method
Secant Iterative method
 
5 random variables
5 random variables5 random variables
5 random variables
 
Limits richard
Limits richardLimits richard
Limits richard
 
Cheatsheet probability
Cheatsheet probabilityCheatsheet probability
Cheatsheet probability
 
Mean, variance, and standard deviation of a Discrete Random Variable
Mean, variance, and standard deviation of a Discrete Random VariableMean, variance, and standard deviation of a Discrete Random Variable
Mean, variance, and standard deviation of a Discrete Random Variable
 
Guia de estudio para aa5
Guia de estudio  para aa5 Guia de estudio  para aa5
Guia de estudio para aa5
 

Similar to statistics1

Runtime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary AlgorithmsRuntime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary Algorithms
Per Kristian Lehre
 
Runtime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary AlgorithmsRuntime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary Algorithms
PK Lehre
 
Briefnts1 events
Briefnts1 eventsBriefnts1 events
Briefnts1 events
ilathahere
 

Similar to statistics1 (20)

Probability distributions
Probability distributions  Probability distributions
Probability distributions
 
PTSP PPT.pdf
PTSP PPT.pdfPTSP PPT.pdf
PTSP PPT.pdf
 
Econometrics 2.pptx
Econometrics 2.pptxEconometrics 2.pptx
Econometrics 2.pptx
 
Frequency14.pptx
Frequency14.pptxFrequency14.pptx
Frequency14.pptx
 
An Introduction To Basic Statistics And Probability
An Introduction To Basic Statistics And ProbabilityAn Introduction To Basic Statistics And Probability
An Introduction To Basic Statistics And Probability
 
Probability cheatsheet
Probability cheatsheetProbability cheatsheet
Probability cheatsheet
 
Chapter-4 combined.pptx
Chapter-4 combined.pptxChapter-4 combined.pptx
Chapter-4 combined.pptx
 
Statistics Formulae for School Students
Statistics Formulae for School StudentsStatistics Formulae for School Students
Statistics Formulae for School Students
 
PhysicsSIG2008-01-Seneviratne
PhysicsSIG2008-01-SeneviratnePhysicsSIG2008-01-Seneviratne
PhysicsSIG2008-01-Seneviratne
 
Runtime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary AlgorithmsRuntime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary Algorithms
 
Runtime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary AlgorithmsRuntime Analysis of Population-based Evolutionary Algorithms
Runtime Analysis of Population-based Evolutionary Algorithms
 
7주차
7주차7주차
7주차
 
ISM_Session_5 _ 23rd and 24th December.pptx
ISM_Session_5 _ 23rd and 24th December.pptxISM_Session_5 _ 23rd and 24th December.pptx
ISM_Session_5 _ 23rd and 24th December.pptx
 
Bayesian statistics
Bayesian statisticsBayesian statistics
Bayesian statistics
 
Unit II PPT.pptx
Unit II PPT.pptxUnit II PPT.pptx
Unit II PPT.pptx
 
NBBC15, Reyjavik, June 08, 2015
NBBC15, Reyjavik, June 08, 2015NBBC15, Reyjavik, June 08, 2015
NBBC15, Reyjavik, June 08, 2015
 
Probability Cheatsheet.pdf
Probability Cheatsheet.pdfProbability Cheatsheet.pdf
Probability Cheatsheet.pdf
 
Statistics-Defined.pdf
Statistics-Defined.pdfStatistics-Defined.pdf
Statistics-Defined.pdf
 
Briefnts1 events
Briefnts1 eventsBriefnts1 events
Briefnts1 events
 
Survival analysis 1
Survival analysis 1Survival analysis 1
Survival analysis 1
 

statistics1