-
Notifications
You must be signed in to change notification settings - Fork 5
/
15.html
715 lines (639 loc) · 29.2 KB
/
15.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>プログラマの為の数学勉強会</title>
<!-- For reveal.js -->
<link rel="stylesheet" href="lib/reveal/css/reveal.css">
<link rel="stylesheet" href="lib/reveal/css/theme/night.css">
<link rel="stylesheet" href="lib/reveal/lib/css/ir_black.css">
<!-- For Graphics -->
<link rel="stylesheet" href="css/graphics.css">
<style>
.reveal .chapter-title {
margin-top: 3em;
}
.reveal {
font-size: 32px;
line-height: 1.4em;
}
.reveal .slides {
text-align: left;
}
.reveal section img {
border: none;
background: 0;
margin-left: 1em;
margin-right: 1em;
box-shadow: none;
}
.reveal strong {
color: yellow;
}
.reveal sup {
font-size: 40%;
}
.reveal table {
margin-top: 0.5em;
margin-bottom: 0.5em;
border: 2px solid lightblue;
}
.reveal pre {
font-size: 0.7em;
}
.reveal pre code {
max-height: 600px;
}
.reveal .note {
font-size: 50%;
}
.reveal .controls div.navigate-up,
.reveal .controls div.navigate-down {
display: none;
}
.reveal .block {
border: solid 2px;
position: relative;
border-radius: 8px;
margin-top: 0.8em;
margin-bottom: 0.8em;
padding: 1em 0.8em 1em 0.8em;
}
.reveal .block:after {
content: "";
display: block;
clear: both;
height: 1px;
overflow: hidden;
}
.reveal .answer {
color: #111111;
}
.reveal .block h4 {
position: absolute;
top: -0.5em;
margin: 0 auto;
background: #111111;
font-weight: bold;
}
</style>
<!-- Setup libraries for RequireJS-->
<script src="lib/require.js"></script>
<script>
requirejs.config({
baseUrl: "js",
paths: {
d3: "../lib/d3/d3.v3.min",
numeric: "../lib/numeric-1.2.6",
MathJax: "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML"
},
shim: {
d3: { exports: "d3" },
numeric: { exports: "numeric" },
MathJax: { exports: "MathJax" }
}
});
</script>
<!-- Initialize MathJax -->
<script type="text/x-mathjax-config">
require(["MathJax"], function (MathJax){
MathJax.Hub.Register.StartupHook("AsciiMath Jax Config", function () {
var AM = MathJax.InputJax.AsciiMath.AM;
AM.symbols.push(
{input:"mathbi",tag:"mstyle",atname:"mathvariant",atval:"bold-italic",
output:"mathbi",tex:null,ttype:AM.TOKEN.UNARY}
);
});
MathJax.Hub.Config({
showProcessingMessages: false,
skipStartupTypeset: false,
tex2jax: {
inlineMath: [ ["\\(","\\)"] ],
displayMath: [ ["\\[","\\]"] ]
}
});
});
</script>
<script>
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section style="text-align: center">
<h1> プログラマの為の<br>数学勉強会<br>第15回</h1>
<span>
(於)ワークスアプリケーションズ<br>
中村晃一<br>
2013年12月19日
</span>
</section>
<section>
<h2>謝辞</h2>
<p>
この会の企画・会場設備の提供をして頂きました<br>
㈱ ワークスアプリケーションズ様<br>
にこの場をお借りして御礼申し上げます。
</p>
</section>
<section>
<h2> この資料について </h2>
<p>
<ul>
<li> <a href="http://nineties.github.com/math-seminar">
http://nineties.github.com/math-seminar
</a>に置いてあります。 </li>
<li> SVGに対応したブラウザで見て下さい。主要なブラウザで古いバージョンでなければ大丈夫だと思います。</li>
<li> 内容の誤り、プログラムのバグは<a href="http://twitter.com/9_ties">@9_ties</a>かkoichi.nakamur AT gmail.comまでご連絡下さい。</li>
<li> サンプルプログラムはPython及びMaximaで記述しています。 </li>
</ul>
</p>
</section>
<section>
<h2 class="chapter-title"> 検定 </h2>
</section>
<section>
<p>
母集団が確率分布 \(D\) に従っているか否かを判断したいとします.
</p>
<p>
その為には, 標本 \(X_1,X_2,\ldots,X_n\) を無作為に抽出して
\[ X_1,X_2,\ldots,X_n \sim D \]
であるという<strong>仮説</strong>の元で実際のデータ \(x_1,x_2,\ldots,x_n\) が得られる確率を考え, 仮説の妥当性を<strong>検定</strong>します.
</p>
<div align="center"> <img width="600px" src="fig/testing.png"> </div>
</section>
<section>
<h2> 母数による仮説検定 </h2>
<p>
母集団の従う分布の種類が既知であり, 母数に対する仮説検定を行う場合を考えます.
</p>
</section>
<section>
<h2> 帰無仮説と対立仮説 </h2>
<p>
統計的に示したい仮説を<strong>対立仮説</strong>とか<strong>実験仮説</strong>などと言い, \(H_1\) と書きます. 対立仮説を否定する仮説を<strong>帰無仮説</strong>と呼び, \(H_0\) と書きます.
</p>
<div class="fragment block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
<p>
ある会社\(X\)は\(X\)社の製品が\(Y\)社の製品より高性能であると主張しています. この主張を統計的に示したいのならば,
\[ \begin{aligned}
\text{帰無仮説}H_0&: \text{$X$社の製品は$Y$社の製品と同性能} \\
\text{対立仮説}H_1&: \text{$X$社の製品は$Y$社の製品より高性能} \\
\end{aligned} \]
といった仮説を立てて, \(H_0\)を否定する事を目指します.
</p>
</div>
</section>
<section>
<h2> 有意水準 </h2>
<p>
帰無仮説\(H_0\)を否定する為には, <strong>仮説\(H_0\)の元ではめったに起こらない事が起きた</strong>という事を示せば良いです.
</p>
<p>
そこで, 適当な定数 \(\alpha\) を定めて, \(H_0\) のもとで
\[ P(\text{実際に生じた事象}) \leq \alpha \]
となった時に, \(H_0\) を <strong>棄却</strong> することにします. この \(\alpha\) を <strong>有意水準</strong> と呼び, \(H_0\) が棄却された時, 検定の結果は<strong>有意である</strong>と言います. また, 棄却される事象の範囲を<strong>棄却域</strong>と言います.
</p>
<p>
\(\alpha\)の値としては, \(0.05\)や\(0.01\)などがよく利用されます.
</p>
</section>
<section>
<p>
検定のやり方をまとめておくと, 以下のようになります.
</p>
<ol>
<li> 帰無仮説\(H_0\)と対立仮説\(H_1\)を立てる. </li>
<li> 有意水準 \(\alpha\) を決める. </li>
<li> 検定に用いる統計量を定めて, \(H_0,H_1\) に基き棄却域を計算する. </li>
<li> 実現値(実際に得られたデータ)に基いて, \(H_0\) を棄却するか否かを決める. </li>
</ol>
</section>
<section>
<p>
細かい話をする前に, 簡単な例を1つみてみましょう.
</p>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
<p>
コインを100回投げた所, 63回表が出たとします. このコインは表が出やすいと言えるでしょうか?有意水準 5% で検定しましょう.
</p>
</div>
<p style="font-size:80%">
コインの出る確率を \(p\) として帰無仮説・対立仮説を
\[ \begin{aligned}
H_0&: p = \frac{1}{2} \\
H_1&: p > \frac{1}{2}
\end{aligned} \]
と設定します. 有意水準は \(\alpha=0.05\) です.<br>
検定に用いる統計量には, 標本平均(表の出る頻度) \(\overline{X}\) を使うことにします.
</p>
</section>
<section style="font-size:80%">
<p>
\(H_0\) の元では, \(\overline{X}\)は(中心極限定理によって)正規分布
\[ N\left(p,\frac{p(1-p)}{n}\right) = N\left(\frac{1}{2}, \frac{1}{400}\right) \]
に従います.
</p>
<p>
\(H_0\)が棄却されるのは\(p=1/2\) よりも上側に大きく外れる場合ですから, 棄却域は\(N(0,1)\) の上側\(\alpha\) 点を\(z_\alpha\) として
\[ \overline{X} \geq \frac{1}{2} + \sqrt{\frac{1}{400}}z_\alpha = 0.58 \]
となります.
先ほどの実験結果では \(\overline{X}=0.63\) なので, この実験結果に基づけば \(H_0\) は棄却され, 例題のコインは表が出やすいものだ結論する事が出来ます.
</p>
</section>
<section>
<p>
今の例題の様に,対立仮説が
\[ \theta > \theta_0\text{とか}\theta_0 < \theta_0 \]
の場合には一般に棄却域が下図のようになります. このような検定を<strong>片側検定</strong>と言います. 棄却域が左右のどちらに来るかを区別して<strong>左側検定・右側検定</strong>と言う事もあります.
<div align="center"> <img width="600px" src="fig/one-side-test.png"> </div>
</section>
<section>
<p>
一方,対立仮説が
\[ \theta \neq \theta_0 \]
のような場合には<strong>両側検定</strong>と言います.
<div align="center"> <img width="600px" src="fig/both-side-test.png"> </div>
</p>
</section>
<section>
<h2> 注意 </h2>
<p>
帰無仮説\(H_0\)が棄却できなかった場合, \(H_0\) が正しいという結論にはならないので注意してください. 「\(H_0\)が誤っているとは言えない」という事と, 「\(H_0\) が正しい」という事は異なります.
</p>
<p>
意味のある結論を導く為には, 帰無仮説は基本的に棄却される必要があります.
</p>
</section>
<section>
<p>
仮説検定の雰囲気はわかったと思うので, 定理をいくつか紹介します.
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 母分散が既知の正規分布(両側検定) </h4>
<p>
独立な標本 \(X_1,X_2,\ldots,X_n\) が \(N(\mu,\sigma^2)\) に従い, \(\sigma^2\) が既知であるとする.<br>
\(\mu\) に関する仮説
\[ \begin{aligned}
H_0&: \mu = \mu_0 \\
H_1&: \mu \neq \mu _0
\end{aligned} \]
を標本平均 \(\overline{X}\) で検定するときの棄却域は
\[ \overline{X} \leq \mu_0 - \frac{\sigma}{\sqrt{n}}z_\alpha, \mu_0 + \frac{\sigma}{\sqrt{n}}z_\alpha \leq \overline{X} \]
である. 但し \(z_\alpha\) は\(N(0,1)\)の両側\(\alpha\)点.
</p>
</div>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 母分散が既知の正規分布(右側検定) </h4>
<p>
独立な標本 \(X_1,X_2,\ldots,X_n\) が \(N(\mu,\sigma^2)\) に従い, \(\sigma^2\) が既知であるとする.<br>
\(\mu\) に関する仮説
\[ \begin{aligned}
H_0&: \mu = \mu_0 \\
H_1&: \mu > \mu _0
\end{aligned} \]
を標本平均 \(\overline{X}\) で検定するときの棄却域は
\[ \mu_0 + \frac{\sigma}{\sqrt{n}}z_\alpha \leq \overline{X} \]
である. 但し \(z_\alpha\) は\(N(0,1)\)の上側\(\alpha\)点.
</p>
</div>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 母分散が未知の正規分布(両側検定) </h4>
<p>
独立な標本 \(X_1,X_2,\ldots,X_n\) が \(N(\mu,\sigma^2)\) に従い, \(\sigma^2\) が未知であるとする.<br>
\(\mu\) に関する仮説
\[ \begin{aligned}
H_0&: \mu = \mu_0 \\
H_1&: \mu \neq \mu _0
\end{aligned} \]
を標本平均 \(\overline{X}\) で検定するときの棄却域は
\[ \overline{X} \leq \mu_0 - \frac{S}{\sqrt{n}}t_\alpha, \mu_0 + \frac{S}{\sqrt{n}}t_\alpha \leq \overline{X} \]
である. 但し \(t_\alpha\) は自由度\(n-1\)の\(t\)分布の両側\(\alpha\)点, \(S^2\)は不偏分散.
</p>
</div>
<p>
片側検定も同様です. 以上の結果は前回やった信頼区間に関する定理とほぼ同じなので, 証明は省略します.
</p>
</section>
<section>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
<p>
あるWebサービスには1分あたり平均\(970\)回アクセスがあるとします. このWebサービスを改良したことの効果を検証しましょう.<br>
そこで,ランダムに100回(各一分間)アクセス回数を測定した所, 標本平均が\(980\)回でした. 改良によって平均アクセス回数は有意に増えたと言えるでしょうか?
</p>
</div>
</section>
<section style="font-size:80%">
<p>
有意水準を \(\alpha=0.05\) とします. 一分あたりのユーザーのアクセス回数はポアソン分布\(Po(\lambda)\) に従うと仮定します. 帰無仮説・対立仮説は
\[ \begin{aligned}
H_0&: \lambda = 970 \\
H_1&: \lambda > 970
\end{aligned} \]
となります. 検定は標本平均 \(\overline{X}\) で行うことにします. \(Po(\lambda)\)の平均・分散は共に\(\lambda\)なので, 中心極限定理より \(H_0\) のもとでは, \(\overline{X} \sim N\left(970, \frac{970}{100}\right) = N(970, 9.7)\) となります. 母分散が既知なので, 棄却域は\(N(0,1)\)の上側\(\alpha\)点\(z_\alpha\approx1.64\)を用いて
\[ \lambda \geq 970 + \sqrt{9.7}\cdot z_\alpha \approx 975 \]
となります. よって, \(980 \geq 975\) なので \(H_0\) を棄却する事が出来ます. ユーザーのアクセス回数は有意に増加したと言えそうです.
</p>
</section>
<section>
<h2> 母平均の差の検定 </h2>
<p>
以下のような母平均の差に関する検定を行い場合もあります.
</p>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
A高校,B高校のそれぞれから, 7人, 9人の生徒をランダムに抽出して, 数学の試験を行った所以下の結果を得たとします.
\[ \begin{aligned}
\text{A高校}&: 69, 75, 63, 78, 54, 84, 72\quad\text{(平均$70.7$)} \\
\text{B高校}&: 89, 77, 72, 48, 69, 83, 53, 65, 59\quad\text{(平均$68.3$)}
\end{aligned} \]
<p> A高校出身者の方が有意に優れていると言えるでしょうか? </p>
</div>
</section>
<section>
<p>
以下の定理が必要となります.
</p>
<div class="block" style="border-color:pink;font-size:80%">
<p> \(X_1,X_2\)が独立であるとする. \( X_1\sim N(\mu_1,\sigma_1^2),X_2\sim N(\mu_2,\sigma_2^2) \)ならば
\[ X_1-X_2 \sim N(\mu_1-\mu_2, \sigma_1^2 + \sigma_2^2) \]
である. </p>
</div>
<p>
これは第13回に説明した正規分布の再生性から言えます.
</p>
</section>
<section>
<p> 先ほどの問題に利用してみましょう. </p>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
A高校,B高校のそれぞれから, 7人, 9人の生徒をランダムに抽出して, 数学の試験を行った所以下の結果を得たとします.
\[ \begin{aligned}
\text{A高校}&: 69, 75, 73, 78, 85, 84, 72\quad\text{(平均$76.6$)} \\
\text{B高校}&: 79, 77, 72, 48, 89, 73, 53, 65, 59\quad\text{(平均$68.3$)}
\end{aligned} \]
<p> A高校の生徒の方が有意に優れていると言えるでしょうか? 但し, 母分散はそれぞれ60,93であるとします. </p>
</div>
</section>
<section style="font-size:80%">
<p>
有意水準を\(\alpha=0.05\)とします.<br>
A,B高校の生徒の数学の成績の母集団が正規分布 \(N(\mu_A,\sigma_A^2),N(\mu_B,\sigma_B^2)\) に従うと仮定し, 帰無仮説・対立仮説を
\[ \begin{aligned}
H_0&: \mu_A = \mu_B \\
H_1&: \mu_A > \mu_B
\end{aligned} \]
とします. A,B高校それぞれの標本平均を\(\overline{X}_A,\overline{X}_B\)とし, \(\overline{X}_A-\overline{X}_B\) で検定を行います.
\( \overline{X}_A \sim N(\mu_A,\sigma_A^2/7),\overline{X}_B\sim N(\mu_B,\sigma_B^2/9)\)なので,
仮説\(H_0\)のもとでは
\[ \overline{X}_A-\overline{X}_B \sim N(\mu_A-\mu_B,\frac{\sigma_A^2}{7}+\frac{\sigma_B^2}{9}) = N(0, 18.9) \]
となるので, 棄却域は\(N(0,1)\)の上側\(\alpha\)点\(z_\alpha\approx1.64\)を用いて
\[ \overline{X}_A-\overline{X}_B \geq 0 + \sqrt{18.9}\cdot z_\alpha \approx 7.2 \]
となります. 実際には \(\overline{X}_A-\overline{X}_B = 8.2\) であったので, \(H_0\) を棄却する事が出来ます. よって,この検定ではA高校の生徒の方が優れていると結論できます.
</p>
</section>
<section>
<p>
今の問題では母分散を既知としましたが,母分散が未知の場合には以下の定理を利用する事が出来ます.
</p>
<div class="block" style="border-color:pink;font-size:90%">
<p>
\(X_1,X_2,\ldots,X_m\sim N(\mu_1,\sigma^2)\), \(Y_1,Y_2,\ldots,Y_n\sim N(\mu_2,\sigma^2)\) が全て独立な確率変数であるならば,
\[ S^2 = \frac{\sum_{i=1}^m(X_i-\overline{X})^2 + \sum_{i=1}^n(Y_i-\overline{Y})^2}{m+n-2} \]
として,
\[
T = \frac{\overline{X}-\overline{Y}-(\mu_1-\mu_2)}{\sqrt{S^2/m+S^2/n}} \]
で定まる確率変数\(T\)は自由度\(m+n-2\)の\(t\)分布に従う.
</p>
</div>
</section>
<section>
<p> 先ほどの問題で分散が未知の場合を考えましょう. </p>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
A高校,B高校のそれぞれから, 7人, 9人の生徒をランダムに抽出して, 数学の試験を行った所以下の結果を得たとします.
\[ \begin{aligned}
\text{A高校}&: 69, 75, 73, 78, 85, 84, 72\quad\text{(平均$76.6$)} \\
\text{B高校}&: 79, 77, 72, 48, 89, 73, 53, 65, 59\quad\text{(平均$68.3$)}
\end{aligned} \]
<p> A高校の生徒の方が有意に優れていると言えるでしょうか? <strong>母分散はわかりませんが等しいとします.</strong> </p>
</div>
</section>
<section style="font-size:70%">
<p>
有意水準を\(\alpha=0.05\)とします.<br>
A,B高校の生徒の数学の成績の母集団が正規分布 \(N(\mu_A,\sigma^2),N(\mu_B,\sigma^2)\) に従うと仮定し, 帰無仮説・対立仮説を
\[ \begin{aligned}
H_0&: \mu_A = \mu_B \\
H_1&: \mu_A > \mu_B
\end{aligned} \]
とします. A,B高校それぞれの標本平均を\(\overline{X}_A,\overline{X}_B\)とし, \(\overline{X}_A-\overline{X}_B\) で検定を行います.
仮説\(H_0\)のもとでは\(\mu_A-\mu_B=0\)なので,
\[ T = \frac{\overline{X}_A-\overline{X}_B}{\sqrt{S^2/7+S^2/9}} \]
が 自由度 \(7+9-2=14\) の\(t\)分布に従います. よって \(t\) 分布の上側 \(\alpha\) 点が \(t_\alpha = 1.76\) なので棄却域は \( T \geq 1.76 \) となります. 実際に計算してみると,
\[ S^2 = \frac{\sum_{i=1}^m(X_i-\overline{X})^2 + \sum_{i=1}^n(Y_i-\overline{Y})^2}{m+n-2} = 116 \]
なので,
\[ T = \frac{76.6-68.3}{\sqrt{116/7+116/9}} = 1.53 \]
となり, この場合は\(H_0\)を棄却する事が出来ません.
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 母分散の検定 </h4>
<p>
独立な標本 \(X_1,X_2,\ldots,X_n\) が \(N(\mu,\sigma^2)\) に従うとする.
\(\sigma^2\) に関する仮説
\[ \begin{aligned}
H_0&: \sigma = \sigma_0 \\
H_1&: \sigma \neq \sigma _0
\end{aligned} \]
を標本分散\(s^2\)で検定するときの棄却域は,
\[ s^2 \leq \frac{\chi^2_{n-1}(1-\alpha/2)}{n}, \frac{\chi^2_{n-1}(\alpha/2)}{n}\leq s^2 \]
である. 但し \(\chi^2_{n-1}(\alpha)\) は自由度\(n-1\)の\(\chi^2\)分布の上側\(\alpha\)点.
</p>
</div>
</section>
<section>
<p>
先ほど, 母平均の差を検定しましたが, 同様に母分散の差
\[ \sigma_1^2 - \sigma_2^2 \]
を検定したい場合もあります.
</p>
<p> これを直接考えるのは難しいのですが, 代わりに母分散の比
\[ \frac{\sigma_1^2}{\sigma_2^2} \]
を用いて検定が行う事が出来ます.
</p>
</section>
<section>
<p>
母分散の比の推定・検定の為には以下の分布が必要になります.
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> F分布 </h4>
<p>
\(X\sim \chi^2_m, Y\sim \chi^2_n\)で \(X,Y\) が独立である時,
\[ F = \frac{X/m}{Y/n} \]
で定まる確率変数の従う分布を自由度\((m,n)\)の<strong>F分布</strong>と言い, \(F(m,n)\) と書く.
</p>
</div>
</section>
<section>
<p>
F分布の密度関数のグラフは例えば以下のようになります.
</p>
<div align="center"> <img width="700px" src="fig/f.png"> </div>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<p>
\(X_1,X_2,\ldots,X_m\sim N(\mu_1,\sigma_1^2),Y_1,Y_2,\ldots,Y_n\sim N(\mu_2,\sigma_2^2)\) で全ての確率変数が独立である時,
\[ F= \frac{\sigma_2^2}{\sigma_1^2}\frac{S_1^2}{S_2^2} \]
は自由度\((m-1,n-1)\)のF分布に従う. ただし, \(S_1^2\) は\(X_1,X_2,\ldots,X_m\)の不偏分散, \(S_2^2\)は\(Y_1,Y_2,\ldots,Y_n\)の不偏分散である.
</p>
</div>
</section>
<section>
<p> 先ほどの問題で分散の検定をしましょう. </p>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
A高校,B高校のそれぞれから, 7人, 9人の生徒をランダムに抽出して, 数学の試験を行った所以下の結果を得たとします.
\[ \begin{aligned}
\text{A高校}&: 69, 75, 73, 78, 85, 84, 72\quad\text{(平均$76.6$)} \\
\text{B高校}&: 79, 77, 72, 48, 89, 73, 53, 65, 59\quad\text{(平均$68.3$)}
\end{aligned} \]
<p> 各高校の数学の成績の母分散は異なると言えるでしょうか? </p>
</div>
</section>
<section style="font-size:80%">
<p>
有意水準を\(\alpha=0.05\)とします.<br>
A,B高校の生徒の数学の成績の母集団が正規分布 \(N(\mu_A,\sigma_A^2),N(\mu_B,\sigma_B^2)\) に従うと仮定し, 帰無仮説・対立仮説を
\[ \begin{aligned}
H_0&: \sigma_A^2/\sigma_B^2 = 1\\
H_1&: \sigma_A^2/\sigma_B^2 \neq 1
\end{aligned} \]
とします. A,B高校それぞれの不偏分散を\(S_A^2,S_B^2\) とすると \(H_0\) のもとで
\[ F=\frac{\sigma_B^2}{\sigma_A^2}\frac{S_A^2}{S_B^2} = \frac{S_A^2}{S_B^2} \]
が自由度\((7-1,9-1)=(6,8)\) のF分布に従います. この分布の上側\(\alpha\)点を\(F_{6,8}(\alpha)\)と書くと
\[ \mathrm{F}_{6,8}(\alpha/2) = 4.65,\mathrm{F}_{6,8}(1-\alpha/2) = 0.18 \]
であるので, 棄却域は
\[ F\leq 0.18, 4.65\leq F \]
となります. ここで, 実際の値は\(F=70.3/184.7=0.21\) であるので\(H_0\)を棄却する事は出来ません.
</p>
</section>
<section>
<p>
以上が母数による仮説検定の基本です. 他にも様々な場合があり, 個々の定理を覚えるのは大変なので理屈をよく理解するようにしてください.
</p>
</section>
<section>
<h2> 今回はここで終わります。 </h2>
<p>
標本数の決定までやろうと思いましたが, 資料作成が間に合いませんでした. すみません.
</p>
<p>
次回は, 母分散の種類が未知の場合の検定, 標本数の計算, 多変量分布について解説する予定です.
</p>
</section>
</div>
</div>
<script src="lib/reveal/lib/js/head.min.js"></script>
<script src="lib/reveal/js/reveal.js"></script>
<script>
Reveal.initialize({
width: 960,
height: 640,
controls: true,
progress: false,
history: true,
overview: false,
touch: true,
center: false,
rollingLinks: false,
transition: "page",
transitionSpeed: "default",
// When scale != 1, positions of mouse events will be incorrect.
minScale: 1.0,
maxScale: 1.0,
dependencies: [
{ src: "lib/reveal/lib/js/classList.js", condition: function() { return !document.body.classList; } },
{ src: "lib/reveal/plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: "lib/reveal/plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } },
{ src: "lib/reveal/plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }
]
});
// register event listeners
require(["MathJax"], function (MathJax) {
// Delay typesetting of slides
function typeset (idx) {
for (var i = idx - 2, n = idx + 2; i <= n; i++) {
var slide = Reveal.getSlide(i);
if (!slide) continue;
if (!slide.typeset) {
MathJax.Hub.Typeset(slide);
slide.typeset = true;
}
}
}
function initializeGraphics (idx) {
for (var i = idx - 2, n = idx + 2; i <= n; i++) {
var slide = Reveal.getSlide(i);
if (!slide) continue;
var graphics = slide.getAttribute("graphics");
if (graphics && !slide.initialized) {
slide.initialized = true;
(function () {
var p = slide;
require([graphics], function(g) {
if (g.initialize) g.initialize(p);
});
})();
}
}
}
function start (slide) {
var graphics = slide.getAttribute("graphics");
if (graphics) {
require([graphics], function(g) { if (g.start) g.start(slide); });
}
}
function stop (slide) {
var graphics = slide.getAttribute("graphics");
if (graphics) {
require([graphics], function(g) { if (g.stop) g.stop(slide); });
}
}
function simpleEvent (type) {
var event = document.createEvent("HTMLEvents");
event.initEvent(type, true, true);
return event;
}
Reveal.addEventListener("slidechanged", function (event) {
typeset(event.indexh);
initializeGraphics(event.indexh);
start(event.currentSlide);
stop(event.previousSlide);
});
Reveal.addEventListener("fragmentshown", function (event) {
var slide = Reveal.getCurrentSlide();
var graphics = slide.getAttribute("graphics");
if (graphics) {
require([graphics], function(g) { if (g.proceed) g.proceed(slide); });
}
});
console.log(Reveal.getIndices().h);
typeset(Reveal.getIndices().h);
initializeGraphics(Reveal.getIndices().h);
start(Reveal.getCurrentSlide());
});
</script>
</body>
</htl>