-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhow_big_sample.html
2738 lines (2692 loc) · 137 KB
/
how_big_sample.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
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.6.1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>30 How Large a Sample? – Resampling statistics</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
margin-bottom: 0em;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}</style>
<script src="site_libs/quarto-nav/quarto-nav.js"></script>
<script src="site_libs/quarto-nav/headroom.min.js"></script>
<script src="site_libs/clipboard/clipboard.min.js"></script>
<script src="site_libs/quarto-search/autocomplete.umd.js"></script>
<script src="site_libs/quarto-search/fuse.min.js"></script>
<script src="site_libs/quarto-search/quarto-search.js"></script>
<meta name="quarto:offset" content="./">
<link href="./bayes_simulation.html" rel="next">
<link href="./correlation_causation.html" rel="prev">
<script src="site_libs/quarto-html/quarto.js"></script>
<script src="site_libs/quarto-html/popper.min.js"></script>
<script src="site_libs/quarto-html/tippy.umd.min.js"></script>
<script src="site_libs/quarto-html/anchor.min.js"></script>
<link href="site_libs/quarto-html/tippy.css" rel="stylesheet">
<link href="site_libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="site_libs/bootstrap/bootstrap.min.js"></script>
<link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="site_libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script id="quarto-search-options" type="application/json">{
"location": "sidebar",
"copy-button": false,
"collapse-after": 3,
"panel-placement": "start",
"type": "textbox",
"limit": 50,
"keyboard-shortcut": [
"f",
"/",
"s"
],
"show-item-context": false,
"language": {
"search-no-results-text": "No results",
"search-matching-documents-text": "matching documents",
"search-copy-link-title": "Copy link to search",
"search-hide-matches-text": "Hide additional matches",
"search-more-match-text": "more match in this document",
"search-more-matches-text": "more matches in this document",
"search-clear-button-title": "Clear",
"search-text-placeholder": "",
"search-detached-cancel-button-title": "Cancel",
"search-submit-button-title": "Submit",
"search-label": "Search"
}
}</script>
<script type="text/javascript">
$(document).ready(function() {
$("table").addClass('lightable-paper lightable-striped lightable-hover')
});
</script>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="font-awesome.min.css">
</head>
<body class="nav-sidebar floating">
<div id="quarto-search-results"></div>
<header id="quarto-header" class="headroom fixed-top">
<nav class="quarto-secondary-nav">
<div class="container-fluid d-flex">
<button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" role="button" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
<i class="bi bi-layout-text-sidebar-reverse"></i>
</button>
<nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./how_big_sample.html"><span class="chapter-number">30</span> <span class="chapter-title">How Large a Sample?</span></a></li></ol></nav>
<a class="flex-grow-1" role="navigation" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
</a>
<button type="button" class="btn quarto-search-button" aria-label="Search" onclick="window.quartoOpenSearch();">
<i class="bi bi-search"></i>
</button>
</div>
</nav>
</header>
<!-- content -->
<div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article">
<!-- sidebar -->
<nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto">
<div class="pt-lg-2 mt-2 text-left sidebar-header">
<div class="sidebar-title mb-0 py-0">
<a href="./">Resampling statistics</a>
</div>
</div>
<div class="mt-2 flex-shrink-0 align-items-center">
<div class="sidebar-search">
<div id="quarto-search" class="" title="Search"></div>
</div>
</div>
<div class="sidebar-menu-container">
<ul class="list-unstyled mt-1">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./index.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">Python version</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./preface_third.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">Preface to the third edition</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./preface_second.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">Preface to the second edition</span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">1</span> <span class="chapter-title">Introduction</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./resampling_method.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">2</span> <span class="chapter-title">The resampling method</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./what_is_probability.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">3</span> <span class="chapter-title">What is probability?</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./about_technology.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">4</span> <span class="chapter-title">Introducing Python and the Jupyter notebook</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./resampling_with_code.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">5</span> <span class="chapter-title">Resampling with code</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./resampling_with_code2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">6</span> <span class="chapter-title">More resampling with code</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./sampling_tools.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">7</span> <span class="chapter-title">Tools for samples and sampling</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./probability_theory_1a.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">8</span> <span class="chapter-title">Probability Theory, Part 1</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./probability_theory_1b.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">9</span> <span class="chapter-title">Probability Theory Part 1 (continued)</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./more_sampling_tools.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">10</span> <span class="chapter-title">Two puzzles and more tools</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./probability_theory_2_compound.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">11</span> <span class="chapter-title">Probability Theory, Part 2: Compound Probability</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./probability_theory_3.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">12</span> <span class="chapter-title">Probability Theory, Part 3</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./probability_theory_4_finite.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">13</span> <span class="chapter-title">Probability Theory, Part 4: Estimating Probabilities from Finite Universes</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./sampling_variability.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">14</span> <span class="chapter-title">On Variability in Sampling</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./monte_carlo.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">15</span> <span class="chapter-title">The Procedures of Monte Carlo Simulation (and Resampling)</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./standard_scores.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">16</span> <span class="chapter-title">Ranks, Quantiles and Standard Scores</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./inference_ideas.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">17</span> <span class="chapter-title">The Basic Ideas in Statistical Inference</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./inference_intro.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">18</span> <span class="chapter-title">Introduction to Statistical Inference</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./point_estimation.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">19</span> <span class="chapter-title">Point Estimation</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./framing_questions.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">20</span> <span class="chapter-title">Framing Statistical Questions</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./testing_counts_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">21</span> <span class="chapter-title">Hypothesis-Testing with Counted Data, Part 1</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./significance.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">22</span> <span class="chapter-title">The Concept of Statistical Significance in Testing Hypotheses</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./testing_counts_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">23</span> <span class="chapter-title">The Statistics of Hypothesis-Testing with Counted Data, Part 2</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./testing_measured.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">24</span> <span class="chapter-title">The Statistics of Hypothesis-Testing With Measured Data</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./testing_procedures.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">25</span> <span class="chapter-title">General Procedures for Testing Hypotheses</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./confidence_1.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">26</span> <span class="chapter-title">Confidence Intervals, Part 1: Assessing the Accuracy of Samples</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./confidence_2.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">27</span> <span class="chapter-title">Confidence Intervals, Part 2: The Two Approaches to Estimating Confidence Intervals</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./reliability_average.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">28</span> <span class="chapter-title">Some Last Words About the Reliability of Sample Averages</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./correlation_causation.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">29</span> <span class="chapter-title">Correlation and Causation</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./how_big_sample.html" class="sidebar-item-text sidebar-link active">
<span class="menu-text"><span class="chapter-number">30</span> <span class="chapter-title">How Large a Sample?</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./bayes_simulation.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">31</span> <span class="chapter-title">Bayesian Analysis by Simulation</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./references.html" class="sidebar-item-text sidebar-link">
<span class="menu-text">References</span></a>
</div>
</li>
<li class="sidebar-item sidebar-item-section">
<div class="sidebar-item-container">
<a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="true">
<span class="menu-text">Appendices</span></a>
<a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="true" aria-label="Toggle section">
<i class="bi bi-chevron-right ms-2"></i>
</a>
</div>
<ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show">
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./exercise_solutions.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">A</span> <span class="chapter-title">Exercise Solutions</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./technical_note.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">B</span> <span class="chapter-title">Technical Note to the Professional Reader</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./acknowlegements.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">C</span> <span class="chapter-title">Acknowledgements</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./code_topics.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">D</span> <span class="chapter-title">Code topics</span></span></a>
</div>
</li>
<li class="sidebar-item">
<div class="sidebar-item-container">
<a href="./errors_suggestions.html" class="sidebar-item-text sidebar-link">
<span class="menu-text"><span class="chapter-number">E</span> <span class="chapter-title">Errors and suggestions</span></span></a>
</div>
</li>
</ul>
</li>
</ul>
</div>
</nav>
<div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div>
<!-- margin-sidebar -->
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#issues-in-determining-sample-size" id="toc-issues-in-determining-sample-size" class="nav-link active" data-scroll-target="#issues-in-determining-sample-size"><span class="header-section-number">30.1</span> Issues in determining sample size</a></li>
<li><a href="#some-practical-examples" id="toc-some-practical-examples" class="nav-link" data-scroll-target="#some-practical-examples"><span class="header-section-number">30.2</span> Some practical examples</a>
<ul class="collapse">
<li><a href="#sec-proportion-radio" id="toc-sec-proportion-radio" class="nav-link" data-scroll-target="#sec-proportion-radio"><span class="header-section-number">30.2.1</span> Example: what proportion of homes are listening to a radio station?</a></li>
<li><a href="#example-average-weight-gain-for-pig-rations" id="toc-example-average-weight-gain-for-pig-rations" class="nav-link" data-scroll-target="#example-average-weight-gain-for-pig-rations"><span class="header-section-number">30.2.2</span> Example: average weight gain for pig rations</a></li>
</ul></li>
<li><a href="#example-sample-size-for-inference-on-fruit-fly-sex-difference" id="toc-example-sample-size-for-inference-on-fruit-fly-sex-difference" class="nav-link" data-scroll-target="#example-sample-size-for-inference-on-fruit-fly-sex-difference"><span class="header-section-number">30.3</span> Example: sample size for inference on fruit fly sex difference</a>
<ul class="collapse">
<li><a href="#example-sample-size-for-an-internet-provider-poll" id="toc-example-sample-size-for-an-internet-provider-poll" class="nav-link" data-scroll-target="#example-sample-size-for-an-internet-provider-poll"><span class="header-section-number">30.3.1</span> Example: sample size for an internet-provider poll</a></li>
<li><a href="#example-how-large-a-sample-for-pig-rations" id="toc-example-how-large-a-sample-for-pig-rations" class="nav-link" data-scroll-target="#example-how-large-a-sample-for-pig-rations"><span class="header-section-number">30.3.2</span> Example: how large a sample for pig rations?</a></li>
</ul></li>
<li><a href="#step-wise-sample-size-determination" id="toc-step-wise-sample-size-determination" class="nav-link" data-scroll-target="#step-wise-sample-size-determination"><span class="header-section-number">30.4</span> Step-wise sample-size determination</a></li>
<li><a href="#summary" id="toc-summary" class="nav-link" data-scroll-target="#summary"><span class="header-section-number">30.5</span> Summary</a></li>
</ul>
</nav>
</div>
<!-- main -->
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title"><span class="chapter-number">30</span> <span class="chapter-title">How Large a Sample?</span></h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<section id="issues-in-determining-sample-size" class="level2" data-number="30.1">
<h2 data-number="30.1" class="anchored" data-anchor-id="issues-in-determining-sample-size"><span class="header-section-number">30.1</span> Issues in determining sample size</h2>
<p>Sometime in the course of almost every study — preferably early in the planning stage — the researcher must decide how large a sample to take. Deciding the size of sample to take is likely to puzzle and distress you at the beginning of your research career. You have to decide somehow, but there are no simple, obvious guides for the decision.</p>
<p>For example, one of the first studies I worked on was a study of library economics <span class="citation" data-cites="fussler1961patterns">(<a href="references.html#ref-fussler1961patterns" role="doc-biblioref">Fussler and Simon 1961</a>)</span>, which required taking a sample of the books from the library’s collections. Sampling was expensive, and we wanted to take a correctly sized sample. But how large should the sample be? The longer we searched the literature, and the more people we asked, the more frustrated we got because there just did not seem to be a clear-cut answer. Eventually we found out that, even though there are some fairly rational ways of fixing the sample size, most sample sizes in most studies are fixed simply (and irrationally) by the amount of money that is available or by the sample size that similar research has used in the past.</p>
<p>The rational way to choose a sample size is by weighing the benefits you can expect in information against the cost of increasing the sample size. In principle you should continue to increase the sample size until the benefit and cost of an additional sampled unit are equal.<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p>
<p>The benefit of additional information is not easy to estimate even in applied research, and it is extraordinarily difficult to estimate in basic research. Therefore, it has been the practice of researchers to set up target goals of the <em>degree of accuracy</em> they wish to achieve, or to consider various degrees of accuracy that might be achieved with various sample sizes, and then to balance the degree of accuracy with the cost of achieving that accuracy. The bulk of this chapter is devoted to learning how the sample size is related to accuracy in simple situations.</p>
<p>In complex situations, however, and even in simple situations for beginners, you are likely to feel frustrated by the difficulties of relating accuracy to sample size, in which case you cry out to a supervisor, “Don’t give me complicated methods, just give me a rough number based on your greatest experience.” My inclination is to reply to you, “Sometimes life is hard and there is no shortcut.” On the other hand, perhaps you can get more information than misinformation out of knowing sample sizes that have been used in other studies. <a href="#tbl-sample-sizes-opinion" class="quarto-xref">Table <span>30.1</span></a> shows the middle (modal), 25th percentile, and 75th percentile scores for — please keep this in mind — <em>National Opinion Surveys</em> <a href="#tbl-sample-sizes-subgroup" class="quarto-xref">Table <span>30.2</span></a> shows how subgroup analyses affect sample size. The source for both tables is <em>Applied Sampling</em>, by Seymour Sudman <span class="citation" data-cites="sudman1976applied">(<a href="references.html#ref-sudman1976applied" role="doc-biblioref">1976, 86–87</a>)</span> copyright Academic Press, reprinted by permission.</p>
<p>Pretest sample sizes are smaller, of course, perhaps 25-100 observations. Samples in research for Master’s and Ph.D. theses are likely to be closer to a pretest than to national samples.</p>
<div id="tbl-sample-sizes-opinion" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-sample-sizes-opinion-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table 30.1: Common sample sizes for national and regional studies by subject
</figcaption>
<div aria-describedby="tbl-sample-sizes-opinion-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<colgroup>
<col style="width: 30%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 13%">
<col style="width: 10%">
<col style="width: 10%">
<col style="width: 7%">
</colgroup>
<thead>
<tr class="header">
<th rowspan="2">Subject Matter</th>
<th colspan="3">National</th>
<th colspan="3">Regional</th>
</tr>
<tr class="odd">
<th>Mode</th>
<th>Q3</th>
<th>Q1</th>
<th>Mode</th>
<th>Q3</th>
<th>Q1</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Financial</td>
<td>1000+</td>
<td>—</td>
<td>—</td>
<td>100</td>
<td>400</td>
<td>50</td>
</tr>
<tr class="even">
<td>Medical</td>
<td>1000+</td>
<td>1000+</td>
<td>500</td>
<td>1000+</td>
<td>1000+</td>
<td>250</td>
</tr>
<tr class="odd">
<td>Other Behavior</td>
<td>1000+</td>
<td>—</td>
<td>—</td>
<td>700</td>
<td>1000</td>
<td>300</td>
</tr>
<tr class="even">
<td>Attitudes</td>
<td>1000+</td>
<td>1000+</td>
<td>500</td>
<td>700</td>
<td>1000</td>
<td>400</td>
</tr>
<tr class="odd">
<td>Laboratory Experiments</td>
<td>—</td>
<td>—</td>
<td>—</td>
<td>100</td>
<td>200</td>
<td>50</td>
</tr>
</tbody>
</table>
</div>
</figure>
</div>
<div id="tbl-sample-sizes-subgroup" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-sample-sizes-subgroup-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table 30.2: Typical sample sizes for studies of human and institutional populations
</figcaption>
<div aria-describedby="tbl-sample-sizes-subgroup-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<colgroup>
<col style="width: 28%">
<col style="width: 17%">
<col style="width: 16%">
<col style="width: 17%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th rowspan="2">Subgroup analysis</th>
<th colspan="2">People or households</th>
<th colspan="2">Institutions</th>
</tr>
<tr class="odd">
<th>National</th>
<th>Special</th>
<th>National</th>
<th>Special</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>None or few</td>
<td>1000-1500</td>
<td>200-500</td>
<td>200-500</td>
<td>50-200</td>
</tr>
<tr class="even">
<td>Average</td>
<td>1500-2500</td>
<td>500-1000</td>
<td>500-1000</td>
<td>200-500</td>
</tr>
<tr class="odd">
<td>Many</td>
<td>2500+</td>
<td>1000+</td>
<td>1000+</td>
<td>500+</td>
</tr>
</tbody>
</table>
</div>
</figure>
</div>
<p>Once again, the sample size ought to depend on the proportions of the sample that have the characteristics you are interested in, the extent to which you want to learn about subgroups as well as the universe as a whole, and of course the purpose of your study, the value of the information, and the cost. Also, keep in mind that the <em>added</em> information that you obtain from an additional sample observation tends to be smaller as the sample size gets larger. You must quadruple the sample to halve the error.</p>
<p>Now let us consider some specific cases. The first examples taken up here are from the descriptive type of study, and the latter deal with sample sizes in relationship research.</p>
</section>
<section id="some-practical-examples" class="level2" data-number="30.2">
<h2 data-number="30.2" class="anchored" data-anchor-id="some-practical-examples"><span class="header-section-number">30.2</span> Some practical examples</h2>
<section id="sec-proportion-radio" class="level3" data-number="30.2.1">
<h3 data-number="30.2.1" class="anchored" data-anchor-id="sec-proportion-radio"><span class="header-section-number">30.2.1</span> Example: what proportion of homes are listening to a radio station?</h3>
<p>What proportion of the homes in Countryville watch television station WCNT’s ten o’clock news program? That is the question your phone survey aims to answer, and you want to know how many randomly selected homes you must phone to obtain a sufficiently large sample.</p>
<p>Begin by guessing the likeliest answer, say 30 percent in this case. Do not worry if you are off by 5 per cent or even 10 per cent; and you will probably not be further off than that. Select a first-approximation sample size of perhaps 400; this number is selected from my general experience, but it is just a starting point. Then proceed through the first 400 numbers in a random-number table, marking down a <em>yes</em> for numbers 1-3 and <em>no</em> for numbers 4-10 (because 3/10 was your estimate of the proportion listening). Then add the number of <em>yes</em> and <em>no</em>. Carry out perhaps ten sets of such trials, the results of which are in <a href="#tbl-phone-trials" class="quarto-xref">Table <span>30.3</span></a>.</p>
<div id="tbl-phone-trials" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-phone-trials-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table 30.3: Ten example trials from phone survey simulation
</figcaption>
<div aria-describedby="tbl-phone-trials-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<colgroup>
<col style="width: 20%">
<col style="width: 20%">
<col style="width: 19%">
<col style="width: 27%">
</colgroup>
<thead>
<tr class="header">
<th>Trial number</th>
<th>Number “yes”</th>
<th>Number “no”</th>
<th>% difference from expected mean of 30% (120 “yes”)</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>115</td>
<td>285</td>
<td>1.25</td>
</tr>
<tr class="even">
<td>2</td>
<td>119</td>
<td>281</td>
<td>0.25</td>
</tr>
<tr class="odd">
<td>3</td>
<td>116</td>
<td>284</td>
<td>1.00</td>
</tr>
<tr class="even">
<td>4</td>
<td>114</td>
<td>286</td>
<td>1.50</td>
</tr>
<tr class="odd">
<td>5</td>
<td>107</td>
<td>293</td>
<td>3.25</td>
</tr>
<tr class="even">
<td>6</td>
<td>116</td>
<td>284</td>
<td>1.00</td>
</tr>
<tr class="odd">
<td>7</td>
<td>132</td>
<td>268</td>
<td>3.00</td>
</tr>
<tr class="even">
<td>8</td>
<td>123</td>
<td>277</td>
<td>0.75</td>
</tr>
<tr class="odd">
<td>9</td>
<td>121</td>
<td>279</td>
<td>0.25</td>
</tr>
<tr class="even">
<td>10</td>
<td>114</td>
<td>286</td>
<td>1.50</td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td colspan="3">Mean</td>
<td>1.375</td>
</tr>
</tfoot>
</table>
</div>
</figure>
</div>
<p>Based on these ten trials, you can estimate that if you take a sample of 400 and if the “real” viewing level is 30 percent, your average percentage error will be 1.375 percent on either side of 30 percent. That is, with a sample of 400, half the time your error will be greater than 1.375 percent if 3/10 of the universe is listening.</p>
<p>Now you must decide whether the estimated error is small enough for your needs. If you want greater accuracy than a sample of 400 will give you, increase the sample size, using this important rule of thumb: To cut the error in half, you must <em>quadruple</em> the sample size. In other words, if you want a sample that will give you an error of only 0.6875 percent on the average, you must increase the sample size to 1,600 interviews. Similarly, if you cut the sample size to 100, the average error will be only 2.75 percent (double 1.375 percent) on either side of 30 percent. If you distrust this rule of thumb, run ten or so trials on sample sizes of 100 or 1,600, and see what error you can expect to obtain on the average.</p>
<p>If the “real” viewership is 20 percent or 40 percent, instead of 30 percent, the accuracy you will obtain from a sample size of 400 will not be very different from an “actual” viewership of 30 percent, so do not worry about that too much, as long as you are in the right general vicinity.</p>
<p>Accuracy is <em>slightly</em> greater in smaller universes but <em>only</em> slightly. For example, a sample of 400 would give <em>perfect</em> accuracy if Countryville had only 400 residents. And a sample of 400 will give <em>slightly</em> greater accuracy for a town of 800 residents than for a city of 80,000 residents. But, beyond the point at which the sample is a <em>large fraction</em> of the total universe, there is no difference in accuracy with increases in the size of universe. This point is very important. For any given level of accuracy, <em>identical</em> sample sizes give the same level of accuracy for Podunk (population 8,000) or New York City (population 8 million). The <em>ratio</em> of the sample size to the population of Podunk or New York City means nothing at all, even though it intuitively seems to be important.</p>
<p>The size of the sample must depend upon which population or sub-populations you wish to describe. For example, Alfred Kinsey’s sample size for the classic “Sexual Behavior in the Human Male” <span class="citation" data-cites="kinsey1948sexual">(<a href="references.html#ref-kinsey1948sexual" role="doc-biblioref">1948</a>)</span> would have seemed large, by customary practice, for generalizations about the United States population as a whole. But, as Kinsey explains: “… the chief concern of the present study is an understanding of the sexual behavior of <em>each segment of the population</em>, and that it is only secondarily concerned with generalization for the population as a whole.” <span class="citation" data-cites="kinsey1948sexual">(<a href="references.html#ref-kinsey1948sexual" role="doc-biblioref">1948, 82</a>, italics added)</span>. Therefore Kinsey’s sample had to include sub-samples large enough to obtain the desired accuracy in <em>each</em> of these sub-universes. The U.S. Census offers a similar illustration. When the U.S. Bureau of the Census aims to estimate only a total or an average for the United States as a whole — as, for example, in the Current Population Survey estimate of unemployment — a sample of perhaps 50,000 is big enough. But the decennial census aims to make estimates for all the various communities in the country, estimates that require adequate sub-samples in each of these sub-universes; such is the justification for the decennial census’ sample size of so many millions. Television ratings illustrate both types of purpose. Nielsen ratings, for example, are sold primarily to national network advertisers. These advertisers on national television networks usually sell their goods all across the country and are therefore interested primarily in the total United States viewership for a program, rather than in the viewership in various demographic subgroups. The appropriate calculations for Nielsen sample size will therefore refer to the total United States sample. But other organizations sell rating services to <em>local</em> television and radio stations for use in soliciting advertising over the local stations rather than over the network as a whole. Each local sample must then be large enough to provide reasonable accuracy, and, considered as a whole, the samples for the local stations therefore add up to a much larger sample than the Nielsen and other nationwide samples.</p>
<p>The problem may be handled with the following Python program. This program represents viewers with the string <code>'viewers'</code> and non-viewers as <code>'not viewers'</code>. It then asks <span class="python"><code>rnd.choice</code></span> to choose randomly between <code>'viewer'</code> and <code>'not viewer'</code> with a 30% (p=0.3) chance of getting a <code>'viewer'</code> and a 70% chance of getting a <code>'not viewer'</code>. It gets a sample of 400 such numbers, counts (with <span class="python"><code>np.sum</code></span> the “viewers” then finds how much this sample diverges from the expected number of viewers (30% of 400 = 120). It repeats this procedure 10000 times, and then calculates the average divergence.</p>
<div id="nte-viewer_numbers" class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Note 30.1: Notebook: Number of viewers
</div>
</div>
<div class="callout-body-container callout-body">
<div class="nb-links">
<p><a class="notebook-link" href="notebooks/viewer_numbers.ipynb">Download notebook</a> <a class="interact-button" href="./interact/lab/index.html?path=viewer_numbers.ipynb">Interact</a></p>
</div>
</div>
</div>
<div class="nb-start" name="viewer_numbers" title="Number of viewers">
</div>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> numpy <span class="im">as</span> np</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co"># set up the random number generator</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a>rnd <span class="op">=</span> np.random.default_rng()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># set the number of trials</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>n_trials <span class="op">=</span> <span class="dv">10000</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co"># an empty array to store the results</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a>results <span class="op">=</span> np.zeros(n_trials)</span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="co"># What are the options to choose from?</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>options <span class="op">=</span> [<span class="st">'viewer'</span>, <span class="st">'not viewer'</span>]</span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a><span class="co"># do n_trials trials</span></span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> i <span class="kw">in</span> <span class="bu">range</span>(n_trials):</span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># Choose 'viewer' 30% of the time.</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> a <span class="op">=</span> rnd.choice(options, size<span class="op">=</span><span class="dv">400</span>, p<span class="op">=</span>[<span class="fl">0.3</span>, <span class="fl">0.7</span>])</span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> <span class="co"># count the viewers</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> b <span class="op">=</span> np.<span class="bu">sum</span>(a <span class="op">==</span> <span class="st">'viewer'</span>)</span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a> <span class="co"># how different from expected?</span></span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a> c <span class="op">=</span> <span class="dv">120</span> <span class="op">-</span> b</span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a> <span class="co"># absolute value of the difference</span></span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a> d <span class="op">=</span> np.<span class="bu">abs</span>(c)</span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a> <span class="co"># express as a proportion of sample</span></span>
<span id="cb2-26"><a href="#cb2-26" aria-hidden="true" tabindex="-1"></a> e <span class="op">=</span> d <span class="op">/</span> <span class="dv">400</span></span>
<span id="cb2-27"><a href="#cb2-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-28"><a href="#cb2-28" aria-hidden="true" tabindex="-1"></a> <span class="co"># keep score of the result</span></span>
<span id="cb2-29"><a href="#cb2-29" aria-hidden="true" tabindex="-1"></a> results[i] <span class="op">=</span> e</span>
<span id="cb2-30"><a href="#cb2-30" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-31"><a href="#cb2-31" aria-hidden="true" tabindex="-1"></a><span class="co"># find the mean divergence</span></span>
<span id="cb2-32"><a href="#cb2-32" aria-hidden="true" tabindex="-1"></a>k <span class="op">=</span> np.mean(results)</span>
<span id="cb2-33"><a href="#cb2-33" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-34"><a href="#cb2-34" aria-hidden="true" tabindex="-1"></a><span class="co"># Show the result</span></span>
<span id="cb2-35"><a href="#cb2-35" aria-hidden="true" tabindex="-1"></a>k</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>np.float64(0.018184000000000002)</code></pre>
</div>
</div>
<!---
End of notebook.
-->
<div class="nb-end">
</div>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
End of notebook: Number of viewers
</div>
</div>
<div class="callout-body-container callout-body">
<p><code>viewer_numbers</code> starts at <a href="#nte-viewer_numbers" class="quarto-xref">Note <span>30.1</span></a>.</p>
</div>
</div>
<p>It is a simple matter to go back and try a sample size of (say) 1600 rather than 400, and examine the effect on the mean difference.</p>
</section>
<section id="example-average-weight-gain-for-pig-rations" class="level3" data-number="30.2.2">
<h3 data-number="30.2.2" class="anchored" data-anchor-id="example-average-weight-gain-for-pig-rations"><span class="header-section-number">30.2.2</span> Example: average weight gain for pig rations</h3>
<p>This example, like <a href="#sec-proportion-radio" class="quarto-xref"><span>Section 30.2.1</span></a>, illustrates the choice of sample size for estimating a summarization statistic. Later examples deal with sample sizes for probability statistics.</p>
<p>Hark back to the pig-ration problems presented earlier (e.g. <a href="testing_measured.html#sec-pig-rations-measured" class="quarto-xref"><span>Section 24.0.1</span></a>), and consider the following set of pig weight-gains recorded for ration A: 31, 34, 29, 26, 32, 35, 38, 34, 31, 29, 32, 30. Assume that our purpose now is to estimate the average weight gain for ration A, so that the feed company can advertise to farmers how much weight gain to expect from ration A. If the universe is made up of pig weight-gains like those we observed, we can simulate the universe with, say, 1 million weight gains of thirty-one pounds, 1 million of thirty-four pounds, and so on for the twelve observed weight gains. Or, more conveniently, as accuracy will not be affected much, we can make up a universe of say, thirty cards for each thirty-one-pound gain, thirty cards for each thirty-four-pound gains and so forth, yielding a deck of 30 x 12 = 360 cards. Then shuffle, and, just for a starting point, try sample sizes of twelve pigs. The means of the samples for twenty such trials are as in <a href="#tbl-weight-bootstrap" class="quarto-xref">Table <span>30.4</span></a>.</p>
<div id="tbl-weight-bootstrap" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-weight-bootstrap-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table 30.4: Simulated average weight gains from pig ration A
</figcaption>
<div aria-describedby="tbl-weight-bootstrap-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<colgroup>
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
</colgroup>
<thead>
<tr class="header">
<th>Trial</th>
<th>Mean</th>
<th>Absolute deviation of trial mean from actual mean</th>
<th>Trial</th>
<th>Mean</th>
<th>Absolute deviation of trial mean from actual mean</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>31.77</td>
<td>.02</td>
<td>11</td>
<td>32.10</td>
<td>.35</td>
</tr>
<tr class="even">
<td>2</td>
<td>32.27</td>
<td>1.52</td>
<td>12</td>
<td>30.67</td>
<td>1.08</td>
</tr>
<tr class="odd">
<td>3</td>
<td>31.75</td>
<td>.00</td>
<td>13</td>
<td>32.42</td>
<td>.67</td>
</tr>
<tr class="even">
<td>4</td>
<td>30.83</td>
<td>.92</td>
<td>14</td>
<td>30.67</td>
<td>1.08</td>
</tr>
<tr class="odd">
<td>5</td>
<td>30.52</td>
<td>1.23</td>
<td>15</td>
<td>32.25</td>
<td>.50</td>
</tr>
<tr class="even">
<td>6</td>
<td>31.60</td>
<td>.15</td>
<td>16</td>
<td>31.60</td>
<td>.15</td>
</tr>
<tr class="odd">
<td>7</td>
<td>32.46</td>
<td>.71</td>
<td>17</td>
<td>32.33</td>
<td>.58</td>
</tr>
<tr class="even">
<td>8</td>
<td>31.10</td>
<td>.65</td>
<td>18</td>
<td>33.08</td>
<td>1.33</td>
</tr>
<tr class="odd">
<td>9</td>
<td>32.42</td>
<td>.35</td>
<td>19</td>
<td>33.01</td>
<td>1.26</td>
</tr>
<tr class="even">
<td>10</td>
<td>30.60</td>
<td>1.15</td>
<td>20</td>
<td>30.60</td>
<td>1.15</td>
</tr>
</tbody><tfoot>
<tr class="odd">
<td colspan="4">Mean</td>
<td colspan="2">31.75</td>
</tr>
</tfoot>
</table>
</div>
</figure>
</div>
<p>Now ask yourself whether a sample size of twelve pigs gives you enough accuracy. If we sort the absolute deviations, we find the middle two values (the 10th and 11th values) of 20 are 0.67 and 0.71, so the median is the average of these values: 0.69. There is a .5 chance that the mean for any given sample will be more than 0.69 points from the mean of the universe that generates such samples, which in this situation is 31.75 pounds. Is this close enough? That is up to you to decide in light of the purposes for which you are running the experiment. (The logic of the inference you make here is inevitably murky, and use of the term “real mean” can make it even murkier, as is seen in the discussion in <a href="confidence_1.html" class="quarto-xref"><span>Chapter 26</span></a> — <a href="reliability_average.html" class="quarto-xref"><span>Chapter 28</span></a> on confidence intervals.)</p>
<p>To see how accuracy is affected by larger samples, try a sample size of forty-eight “pigs” dealt from the same deck. (But, if the sample size were to be much larger than forty-eight, you might need a “universe” greater than 360 cards.) The results of twenty trials are in <a href="#tbl-weight-forty-eight" class="quarto-xref">Table <span>30.5</span></a>.</p>
<div id="tbl-weight-forty-eight" class="quarto-float quarto-figure quarto-figure-center anchored">
<figure class="quarto-float quarto-float-tbl figure">
<figcaption class="quarto-float-caption-top quarto-float-caption quarto-float-tbl" id="tbl-weight-forty-eight-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Table 30.5: Simulated average weight gain from 48 pigs
</figcaption>
<div aria-describedby="tbl-weight-forty-eight-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<table class="caption-top table">
<colgroup>
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
<col style="width: 15%">
</colgroup>
<thead>
<tr class="header">
<th>Trial</th>
<th>Mean</th>
<th>Absolute deviation of trial mean from actual mean</th>
<th>Trial</th>
<th>Mean</th>
<th>Absolute deviation of trial mean from actual mean</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>1</td>
<td>31.80</td>
<td>.05</td>
<td>11</td>
<td>31.93</td>
<td>.18</td>
</tr>
<tr class="even">
<td>2</td>
<td>32.27</td>
<td>.52</td>
<td>12</td>
<td>32.40</td>
<td>.65</td>
</tr>
<tr class="odd">
<td>3</td>
<td>31.82</td>
<td>.07</td>
<td>13</td>
<td>31.32</td>
<td>.43</td>
</tr>
<tr class="even">
<td>4</td>
<td>31.39</td>
<td>.36</td>
<td>14</td>
<td>32.07</td>
<td>.68</td>
</tr>
<tr class="odd">
<td>5</td>
<td>31.22</td>
<td>.53</td>
<td>15</td>
<td>32.03</td>
<td>.28</td>
</tr>
<tr class="even">
<td>6</td>
<td>31.88</td>
<td>.13</td>
<td>16</td>
<td>31.95</td>