Repository navigation
Expand file tree
/
Copy path06_NormalDistributions_Dynamic.html
More file actions
3830 lines (3729 loc) · 397 KB
/
Copy path06_NormalDistributions_Dynamic.html
File metadata and controls
3830 lines (3729 loc) · 397 KB
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.5.43">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>Topic 6: The Normal Distribution (Dynamic)</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; }
}
</style>
<script src="06_NormalDistributions_Dynamic_files/libs/clipboard/clipboard.min.js"></script>
<script src="06_NormalDistributions_Dynamic_files/libs/quarto-html/quarto.js"></script>
<script src="06_NormalDistributions_Dynamic_files/libs/quarto-html/popper.min.js"></script>
<script src="06_NormalDistributions_Dynamic_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="06_NormalDistributions_Dynamic_files/libs/quarto-html/anchor.min.js"></script>
<link href="06_NormalDistributions_Dynamic_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="06_NormalDistributions_Dynamic_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="06_NormalDistributions_Dynamic_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="06_NormalDistributions_Dynamic_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="06_NormalDistributions_Dynamic_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script src="06_NormalDistributions_Dynamic_files/libs/quarto-contrib/live-runtime/live-runtime.js" type="module"></script>
<link href="06_NormalDistributions_Dynamic_files/libs/quarto-contrib/live-runtime/live-runtime.css" rel="stylesheet">
<script type="module" src="06_NormalDistributions_Dynamic_files/libs/quarto-ojs/quarto-ojs-runtime.js"></script>
<link href="06_NormalDistributions_Dynamic_files/libs/quarto-ojs/quarto-ojs.css" rel="stylesheet">
<style>
.btn-exercise-solution { display: none !important; }
</style>
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
<script type="text/javascript">
const typesetMath = (el) => {
if (window.MathJax) {
// MathJax Typeset
window.MathJax.typeset([el]);
} else if (window.katex) {
// KaTeX Render
var mathElements = el.getElementsByClassName("math");
var macros = [];
for (var i = 0; i < mathElements.length; i++) {
var texText = mathElements[i].firstChild;
if (mathElements[i].tagName == "SPAN") {
window.katex.render(texText.data, mathElements[i], {
displayMode: mathElements[i].classList.contains('display'),
throwOnError: false,
macros: macros,
fleqn: false
});
}
}
}
}
window.Quarto = {
typesetMath
};
</script>
</head>
<body class="fullcontent">
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Topic 6: The Normal Distribution (Dynamic)</h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<div class="cell" data-edit="false">
<div>
<div id="webr-1" class="exercise-cell">
</div>
<script type="webr-1-contents">
eyJjb2RlIjoid2Vicjo6aW5zdGFsbChcImdyYWRldGhpc1wiLCBxdWlldCA9IFRSVUUpXG5saWJyYXJ5KGdyYWRldGhpcylcbm9wdGlvbnMod2Vici5leGVyY2lzZS5jaGVja2VyID0gZnVuY3Rpb24oXG4gIGxhYmVsLCB1c2VyX2NvZGUsIHNvbHV0aW9uX2NvZGUsIGNoZWNrX2NvZGUsIGVudmlyX3Jlc3VsdCwgZXZhbHVhdGVfcmVzdWx0LFxuICBlbnZpcl9wcmVwLCBsYXN0X3ZhbHVlLCBlbmdpbmUsIHN0YWdlLCAuLi5cbikge1xuICBpZiAoaXMubnVsbChjaGVja19jb2RlKSkge1xuICAgICMgTm8gZ3JhZGluZyBjb2RlLCBzbyBqdXN0IHNraXAgZ3JhZGluZ1xuICAgIGludmlzaWJsZShOVUxMKVxuICB9IGVsc2UgaWYgKGlzLm51bGwobGFiZWwpKSB7XG4gICAgbGlzdChcbiAgICAgIGNvcnJlY3QgPSBGQUxTRSxcbiAgICAgIHR5cGUgPSBcIndhcm5pbmdcIixcbiAgICAgIG1lc3NhZ2UgPSBcIkFsbCBleGVyY2lzZXMgbXVzdCBoYXZlIGEgbGFiZWwuXCJcbiAgICApXG4gIH0gZWxzZSBpZiAoaXMubnVsbChzb2x1dGlvbl9jb2RlKSkge1xuICAgIGxpc3QoXG4gICAgICBjb3JyZWN0ID0gRkFMU0UsXG4gICAgICB0eXBlID0gXCJ3YXJuaW5nXCIsXG4gICAgICBtZXNzYWdlID0gaHRtbHRvb2xzOjp0YWdzJGRpdihcbiAgICAgICAgaHRtbHRvb2xzOjp0YWdzJHAoXCJBIHByb2JsZW0gb2NjdXJyZWQgZ3JhZGluZyB0aGlzIGV4ZXJjaXNlLlwiKSxcbiAgICAgICAgaHRtbHRvb2xzOjp0YWdzJHAoXG4gICAgICAgICAgXCJObyBzb2x1dGlvbiBjb2RlIHdhcyBmb3VuZC4gTm90ZSB0aGF0IGdyYWRpbmcgZXhlcmNpc2VzIHVzaW5nIHRoZSBcIixcbiAgICAgICAgICBodG1sdG9vbHM6OnRhZ3MkY29kZShcImdyYWRldGhpc1wiKSxcbiAgICAgICAgICBcInBhY2thZ2UgcmVxdWlyZXMgYSBtb2RlbCBzb2x1dGlvbiB0byBiZSBpbmNsdWRlZCBpbiB0aGUgZG9jdW1lbnQuXCJcbiAgICAgICAgKVxuICAgICAgKVxuICAgIClcbiAgfSBlbHNlIHtcbiAgICBncmFkZXRoaXM6OmdyYWRldGhpc19leGVyY2lzZV9jaGVja2VyKFxuICAgICAgbGFiZWwgPSBsYWJlbCwgc29sdXRpb25fY29kZSA9IHNvbHV0aW9uX2NvZGUsIHVzZXJfY29kZSA9IHVzZXJfY29kZSxcbiAgICAgIGNoZWNrX2NvZGUgPSBjaGVja19jb2RlLCBlbnZpcl9yZXN1bHQgPSBlbnZpcl9yZXN1bHQsXG4gICAgICBldmFsdWF0ZV9yZXN1bHQgPSBldmFsdWF0ZV9yZXN1bHQsIGVudmlyX3ByZXAgPSBlbnZpcl9wcmVwLFxuICAgICAgbGFzdF92YWx1ZSA9IGxhc3RfdmFsdWUsIHN0YWdlID0gc3RhZ2UsIGVuZ2luZSA9IGVuZ2luZSlcbiAgfVxufSkiLCJhdHRyIjp7ImV2YWwiOnRydWUsIm91dHB1dCI6ZmFsc2UsInBlcnNpc3QiOnRydWUsImVkaXQiOmZhbHNlfX0=
</script>
</div>
</div>
<div class="cell" data-edit="false" data-define="ok_response">
<div>
<div id="webr-2" class="exercise-cell">
</div>
<script type="webr-2-contents">
eyJjb2RlIjoiXG5saWJyYXJ5KGh0bWx0b29scylcbm9rX3Jlc3BvbnNlIDwtIGZ1bmN0aW9uKHJlc3BvbnNlLCBuKSB7XG4gIGlmIChpcy5uYShyZXNwb25zZSkpIGRpdihIVE1MKFwiWW91IGhhdmVuJ3QgYW5zd2VyZWQgeWV0LlwiKSwgc3R5bGUgPSBcImNvbG9yOiBwdXJwbGVcIilcbiAgZWxzZSBpZiAocmVzcG9uc2UgPT0gbikgZGl2KEhUTUwoXCJDb3JyZWN0IOKck1wiKSwgc3R5bGUgPSBcImNvbG9yOiBncmVlblwiKVxuICBlbHNlIGRpdihIVE1MKFwiSW5jb3JyZWN0IOKcl1wiKSwgc3R5bGUgPSBcImNvbG9yOiByZWRcIilcbn0iLCJhdHRyIjp7ImVkaXQiOmZhbHNlLCJldmFsIjp0cnVlLCJvdXRwdXQiOmZhbHNlLCJwZXJzaXN0Ijp0cnVlLCJkZWZpbmUiOlsib2tfcmVzcG9uc2UiXX19
</script>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb1" data-startfrom="41" data-source-offset="0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 40;"><span id="cb1-41"><a href="#cb1-41" aria-hidden="true" tabindex="-1"></a><span class="kw">function</span> <span class="fu">ok_checkbox</span>(response<span class="op">,</span> n) {</span>
<span id="cb1-42"><a href="#cb1-42" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (<span class="op">!</span>response <span class="op">||</span> response<span class="op">.</span><span class="at">length</span> <span class="op">===</span> <span class="dv">0</span>) </span>
<span id="cb1-43"><a href="#cb1-43" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="fu">html</span><span class="vs">`<span style="color:purple">You haven't answered yet.</span>`</span><span class="op">;</span></span>
<span id="cb1-44"><a href="#cb1-44" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (response<span class="op">.</span><span class="fu">toString</span>() <span class="op">===</span> n) </span>
<span id="cb1-45"><a href="#cb1-45" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="fu">html</span><span class="vs">`<span style="color:green">Correct ✓</span>`</span><span class="op">;</span></span>
<span id="cb1-46"><a href="#cb1-46" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="fu">html</span><span class="vs">`<span style="color:red">Not Yet! ✗</span>`</span><span class="op">;</span></span>
<span id="cb1-47"><a href="#cb1-47" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div id="ojs-cell-1" data-nodetype="declaration">
</div>
</div>
</div>
<div class="cell" data-context="setup" data-define="["boundary1","boundary2","boundary3","boundary4","boundary5a","boundary5b","boundary6a","boundary6b","boundary7","chickPoxSampSize","chickPox_surprised","chickPox_exact1","chickPox_exact2","chickPox_atmost","chickPox_atleast","chickPox_between_lo","chickPox_between_hi"]">
<div>
<div id="webr-3" class="exercise-cell">
</div>
<script type="webr-3-contents">
eyJjb2RlIjoiXG5saWJyYXJ5KGdncGxvdDIpXG5saWJyYXJ5KGpzb25saXRlKVxubGlicmFyeShiYXNlNjRlbmMpXG5cbmJvdW5kYXJ5MSA8LSByb3VuZChydW5pZigxLCAwLjc1LCAyKSwgMilcbmJvdW5kYXJ5MiA8LSByb3VuZChydW5pZigxLCAtMiwgLTEuNSksIDIpXG5ib3VuZGFyeTMgPC0gcm91bmQocnVuaWYoMSwgLTIuNSwgLTAuNzUpLCAyKVxuYm91bmRhcnk0IDwtIHJvdW5kKHJ1bmlmKDEsIDAuNzUsIDIuNSksIDIpXG5ib3VuZGFyeTVhIDwtIHJvdW5kKHJ1bmlmKDEsIC0xLjUsIC0wLjc1KSwgMilcbmJvdW5kYXJ5NWIgPC0gcm91bmQocnVuaWYoMSwgMSwgMi41KSwgMilcbmJvdW5kYXJ5NmEgPC0gcm91bmQocnVuaWYoMSwgLTEuNSwgLTAuNzUpLCAyKVxuYm91bmRhcnk2YiA8LSByb3VuZChydW5pZigxLCAxLjUsIDIuNSksIDIpXG5ib3VuZGFyeTcgPC0gcm91bmQocnVuaWYoMSwgMSwgMi41KSwgMilcbmNoaWNrUG94U2FtcFNpemUgPC0gc2FtcGxlKDUwOjE1MCwgc2l6ZSA9IDEpXG5cbiMgRGVyaXZlZCBjaGlja2VucG94IHZhbHVlc1xuY2hpY2tQb3hfc3VycHJpc2VkICAgPC0gZmxvb3IoY2hpY2tQb3hTYW1wU2l6ZSAqIDAuOSAtIDMuNSAqIHNxcnQoY2hpY2tQb3hTYW1wU2l6ZSAqIDAuOSAqIDAuMSkpXG5jaGlja1BveF9leGFjdDEgICAgICA8LSBmbG9vcigwLjkgKiBjaGlja1BveFNhbXBTaXplKVxuY2hpY2tQb3hfZXhhY3QyICAgICAgPC0gZmxvb3IoMC4xICogY2hpY2tQb3hTYW1wU2l6ZSlcbmNoaWNrUG94X2F0bW9zdCAgICAgIDwtIGZsb29yKDAuNzUgKiBjaGlja1BveFNhbXBTaXplKVxuY2hpY2tQb3hfYXRsZWFzdCAgICAgPC0gZmxvb3IoMC45NSAqIGNoaWNrUG94U2FtcFNpemUpXG5jaGlja1BveF9iZXR3ZWVuX2xvICA8LSBmbG9vcigwLjggKiBjaGlja1BveFNhbXBTaXplKVxuY2hpY2tQb3hfYmV0d2Vlbl9oaSAgPC0gZmxvb3IoMC45ICogY2hpY2tQb3hTYW1wU2l6ZSlcblxuZXhlcmNpc2VfcmVzdWx0cyA8LSBsaXN0KFxuICBub3RlYm9vayAgICAgICAgICAgPSBcIlRvcGljIDY6IFRoZSBOb3JtYWwgRGlzdHJpYnV0aW9uXCIsXG4gIHBub3JtX2V4MSAgICAgICAgICA9IFwidW5hdHRlbXB0ZWRcIixcbiAgcG5vcm1fZXgyICAgICAgICAgID0gXCJ1bmF0dGVtcHRlZFwiLFxuICBwbm9ybV9leDMgICAgICAgICAgPSBcInVuYXR0ZW1wdGVkXCIsXG4gIHBub3JtX2V4NCAgICAgICAgICA9IFwidW5hdHRlbXB0ZWRcIixcbiAgcG5vcm1fZXg1ICAgICAgICAgID0gXCJ1bmF0dGVtcHRlZFwiLFxuICBwbm9ybV9leDYgICAgICAgICAgPSBcInVuYXR0ZW1wdGVkXCIsXG4gIHBub3JtX2V4NyAgICAgICAgICA9IFwidW5hdHRlbXB0ZWRcIixcbiAgZmluZF9wZXJjZW50aWxlICAgID0gXCJ1bmF0dGVtcHRlZFwiLFxuICBjaGlja19wb3hfZXhwICAgICAgPSBcInVuYXR0ZW1wdGVkXCIsXG4gIGNoaWNrX3BveF9zZCAgICAgICA9IFwidW5hdHRlbXB0ZWRcIixcbiAgY2hpY2tfcG94X2V4YWN0MSAgID0gXCJ1bmF0dGVtcHRlZFwiLFxuICBjaGlja19wb3hfZXhhY3QyICAgPSBcInVuYXR0ZW1wdGVkXCIsXG4gIGNoaWNrX3BveF9hdG1vc3QgICA9IFwidW5hdHRlbXB0ZWRcIixcbiAgY2hpY2tfcG94X2F0bGVhc3QgID0gXCJ1bmF0dGVtcHRlZFwiLFxuICBjaGlja19wb3hfYmV0d2VlbiAgPSBcInVuYXR0ZW1wdGVkXCIsXG4gIHpfc2NvcmVfUVIgICAgICAgICA9IFwidW5hdHRlbXB0ZWRcIixcbiAgel9zY29yZV9WUiAgICAgICAgID0gXCJ1bmF0dGVtcHRlZFwiLFxuICBHUkVfUVJfcGVyY2VudGlsZSAgPSBcInVuYXR0ZW1wdGVkXCIsXG4gIEdSRV9WUl9hYm92ZSAgICAgICA9IFwidW5hdHRlbXB0ZWRcIlxuKSIsImF0dHIiOnsiZWRpdCI6ZmFsc2UsIm91dHB1dCI6ZmFsc2UsImVjaG8iOmZhbHNlLCJldmFsIjp0cnVlLCJjb250ZXh0Ijoic2V0dXAiLCJwZXJzaXN0Ijp0cnVlLCJkZWZpbmUiOlsiYm91bmRhcnkxIiwiYm91bmRhcnkyIiwiYm91bmRhcnkzIiwiYm91bmRhcnk0IiwiYm91bmRhcnk1YSIsImJvdW5kYXJ5NWIiLCJib3VuZGFyeTZhIiwiYm91bmRhcnk2YiIsImJvdW5kYXJ5NyIsImNoaWNrUG94U2FtcFNpemUiLCJjaGlja1BveF9zdXJwcmlzZWQiLCJjaGlja1BveF9leGFjdDEiLCJjaGlja1BveF9leGFjdDIiLCJjaGlja1BveF9hdG1vc3QiLCJjaGlja1BveF9hdGxlYXN0IiwiY2hpY2tQb3hfYmV0d2Vlbl9sbyIsImNoaWNrUG94X2JldHdlZW5faGkiXX19
</script>
</div>
</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">
About
</div>
</div>
<div class="callout-body-container callout-body">
<p>This activity covers working with normally distributed data, including the calculation of probabilities and percentiles, and introduces the notion of the z-score.</p>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb2" data-startfrom="136" data-source-offset="0"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 135;"><span id="cb2-136"><a href="#cb2-136" aria-hidden="true" tabindex="-1"></a>{</span>
<span id="cb2-137"><a href="#cb2-137" aria-hidden="true" tabindex="-1"></a> <span class="kw">const</span> btn <span class="op">=</span> <span class="fu">html</span><span class="vs">`<button style="</span></span>
<span id="cb2-138"><a href="#cb2-138" aria-hidden="true" tabindex="-1"></a><span class="vs"> background: #436b95;</span></span>
<span id="cb2-139"><a href="#cb2-139" aria-hidden="true" tabindex="-1"></a><span class="vs"> color: white;</span></span>
<span id="cb2-140"><a href="#cb2-140" aria-hidden="true" tabindex="-1"></a><span class="vs"> border: none;</span></span>
<span id="cb2-141"><a href="#cb2-141" aria-hidden="true" tabindex="-1"></a><span class="vs"> padding: 8px 16px;</span></span>
<span id="cb2-142"><a href="#cb2-142" aria-hidden="true" tabindex="-1"></a><span class="vs"> border-radius: 4px;</span></span>
<span id="cb2-143"><a href="#cb2-143" aria-hidden="true" tabindex="-1"></a><span class="vs"> cursor: pointer;</span></span>
<span id="cb2-144"><a href="#cb2-144" aria-hidden="true" tabindex="-1"></a><span class="vs"> font-size: 0.9em;</span></span>
<span id="cb2-145"><a href="#cb2-145" aria-hidden="true" tabindex="-1"></a><span class="vs"> ">🔄 Reset My Responses</button>`</span><span class="op">;</span></span>
<span id="cb2-146"><a href="#cb2-146" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-147"><a href="#cb2-147" aria-hidden="true" tabindex="-1"></a> btn<span class="op">.</span><span class="at">onclick</span> <span class="op">=</span> () <span class="kw">=></span> {</span>
<span id="cb2-148"><a href="#cb2-148" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">confirm</span>(<span class="st">'Reset all responses for this activity? This cannot be undone.'</span>)) {</span>
<span id="cb2-149"><a href="#cb2-149" aria-hidden="true" tabindex="-1"></a> <span class="bu">Object</span><span class="op">.</span><span class="fu">keys</span>(localStorage)</span>
<span id="cb2-150"><a href="#cb2-150" aria-hidden="true" tabindex="-1"></a> <span class="op">.</span><span class="fu">filter</span>(k <span class="kw">=></span> k<span class="op">.</span><span class="fu">endsWith</span>(<span class="st">'_selected_t6d'</span>) <span class="op">||</span> k<span class="op">.</span><span class="fu">endsWith</span>(<span class="st">'_correct_t6d'</span>) <span class="op">||</span> k<span class="op">.</span><span class="fu">endsWith</span>(<span class="st">'_result_t6d'</span>))</span>
<span id="cb2-151"><a href="#cb2-151" aria-hidden="true" tabindex="-1"></a> <span class="op">.</span><span class="fu">forEach</span>(k <span class="kw">=></span> localStorage<span class="op">.</span><span class="fu">removeItem</span>(k))<span class="op">;</span></span>
<span id="cb2-152"><a href="#cb2-152" aria-hidden="true" tabindex="-1"></a> location<span class="op">.</span><span class="fu">reload</span>()<span class="op">;</span></span>
<span id="cb2-153"><a href="#cb2-153" aria-hidden="true" tabindex="-1"></a> }</span>
<span id="cb2-154"><a href="#cb2-154" aria-hidden="true" tabindex="-1"></a> }<span class="op">;</span></span>
<span id="cb2-155"><a href="#cb2-155" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-156"><a href="#cb2-156" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> btn<span class="op">;</span></span>
<span id="cb2-157"><a href="#cb2-157" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div id="ojs-cell-2" data-nodetype="expression">
</div>
</div>
</div>
<p><em>Note.</em> The button above resets multiple choice and checkbox questions. Currently, resetting code cells must be done manually via hitting the <em>Start Over</em> button on each individual interactive cell.</p>
</div>
</div>
<section id="the-normal-distribution" class="level2">
<h2 class="anchored" data-anchor-id="the-normal-distribution">The Normal Distribution</h2>
<p>Throughout this activity we’ll investigate the probability distribution that is most central to our study of statistics: the normal distribution. If we are confident that our data are nearly normal, that opens the door for us to leverage many powerful statistical methods. This activity gives you practice working with normally distributed data.</p>
</section>
<section id="objectives" class="level2">
<h2 class="anchored" data-anchor-id="objectives">Objectives</h2>
<p><strong>Workbook Objectives:</strong> After completing this workbook you should be able to:</p>
<ul>
<li>Compute probabilities of events from populations well-modeled by a normal distribution.</li>
<li>Given a variable <span class="math inline">\(X\)</span> which follows an assumed normal distribution, compute and interpret various percentile thresholds for <span class="math inline">\(X\)</span>.</li>
<li>Identify scenarios to which the normal or binomial distributions can be applied, and use the appropriate distribution to answer various probability-related questions.</li>
</ul>
</section>
<section id="the-normal-distribution-1" class="level2">
<h2 class="anchored" data-anchor-id="the-normal-distribution-1">The Normal Distribution</h2>
<p><strong>Definition:</strong> If a random variable <span class="math inline">\(X\)</span> is normally distributed with mean <span class="math inline">\(\mu\)</span> and standard deviation <span class="math inline">\(\sigma\)</span>, we often write <span class="math inline">\(X\sim N\left(\mu, \sigma\right)\)</span>. Three different normal distributions appear below.</p>
<ul>
<li>In <strong><span style="color:blue">blue</span></strong> is a normal distribution with <span class="math inline">\(\mu = 0\)</span> and <span class="math inline">\(\sigma = 5\)</span></li>
<li>In <strong><span style="color:red">red</span></strong> is a normal distribution with <span class="math inline">\(\mu = 0\)</span> and <span class="math inline">\(\sigma = 0.5\)</span></li>
<li>In <strong>black</strong> is a normal distribution with <span class="math inline">\(\mu = 0\)</span> and <span class="math inline">\(\sigma = 1\)</span> (the so-called <em>Standard Normal Distribution</em>)</li>
</ul>
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="06_NormalDistributions_Dynamic_files/figure-html/unnamed-chunk-7-1.png" class="img-fluid figure-img" width="672"></p>
</figure>
</div>
</div>
</div>
<p>Notice that all three distributions are bell-shaped and are centered at their mean (<span class="math inline">\(\mu = 0\)</span>). The larger the standard deviation, the shorter and wider the curve, while the smaller the standard deviation, the taller and more narrow the curve.</p>
<p>Given that <span class="math inline">\(X\sim N\left(\mu, \sigma\right)\)</span>, we can compute probabilities associated with observed values of <span class="math inline">\(X\)</span> by finding the corresponding area beneath the normal curve having mean <span class="math inline">\(\mu\)</span> and standard deviation <span class="math inline">\(\sigma\)</span>.</p>
<p><strong>Properties of the Normal Distribution:</strong> Consider <span class="math inline">\(X\sim N\left(\mu, \sigma\right)\)</span>.</p>
<ul>
<li>The area beneath the entire distribution is 1 (since this is equivalent to the probability that <span class="math inline">\(X\)</span> takes on any of its possible values).</li>
</ul>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="06_NormalDistributions_Dynamic_files/figure-html/unnamed-chunk-8-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="288"></p>
</figure>
</div>
</div>
</div>
<ul>
<li><span class="math inline">\(\displaystyle{\mathbb{P}\left[X\leq \mu\right] = \mathbb{P}\left[X\geq \mu\right] = 0.5}\)</span> (the area underneath a full half of the distribution is 0.5)</li>
</ul>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="06_NormalDistributions_Dynamic_files/figure-html/unnamed-chunk-9-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="576"></p>
</figure>
</div>
</div>
</div>
<ul>
<li>The distribution is symmetric. In symbols, we write <span class="math inline">\(\mathbb{P}\left[X\leq \mu - k\right] = \mathbb{P}\left[X \geq \mu + k\right]\)</span> for any <span class="math inline">\(k\)</span>. Geometrically, this means that corresponding lower-tail (left-tail) and upper-tail (right-tail) areas are equal.</li>
</ul>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="06_NormalDistributions_Dynamic_files/figure-html/unnamed-chunk-10-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="576"></p>
</figure>
</div>
</div>
</div>
<ul>
<li><span class="math inline">\(\displaystyle{\mathbb{P}\left[X = k\right] = 0}\)</span> (the probability that <span class="math inline">\(X\)</span> takes on any prescribed value exactly is <span class="math inline">\(0\)</span>)</li>
</ul>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="06_NormalDistributions_Dynamic_files/figure-html/unnamed-chunk-11-1.png" class="img-fluid quarto-figure quarto-figure-center figure-img" width="288"></p>
</figure>
</div>
</div>
</div>
<div class="callout callout-style-default callout-important 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">
Important
</div>
</div>
<div class="callout-body-container callout-body">
<p>Unlike the binomial distribution, where the distinction between <em>at least</em> and <em>more than</em> required careful adjustment, the probability that a continuous variable <span class="math inline">\(X\)</span> takes on any prescribed value exactly is <span class="math inline">\(0\)</span> (that is, <span class="math inline">\(\mathbb{P}\left[X = k\right] = 0\)</span>). This means there is no difference between <span class="math inline">\(\mathbb{P}\left[X \leq k\right]\)</span> and <span class="math inline">\(\mathbb{P}\left[X < k\right]\)</span>. Similarly, there is no difference between <span class="math inline">\(\mathbb{P}\left[X \geq k\right]\)</span> and <span class="math inline">\(\mathbb{P}\left[X > k\right]\)</span>.</p>
</div>
</div>
<p>Sometimes it is useful to be able to estimate probabilities or to estimate the proportion of a population that falls into a range, as long as the population is nearly normal. A convenient set of rough estimates come from the <em>Empirical Rule</em>.</p>
<div class="callout callout-style-default callout-tip 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">
The Empirical Rule
</div>
</div>
<div class="callout-body-container callout-body">
<p>If <span class="math inline">\(X\sim N\left(\mu, \sigma\right)\)</span>, then</p>
<ul>
<li><span class="math inline">\(\mathbb{P}\left[\mu - \sigma \leq X\leq \mu + \sigma\right] \approx 0.68\)</span> — that is, about 68% of observations lie within one standard deviation of the mean.</li>
<li><span class="math inline">\(\mathbb{P}\left[\mu - 2\sigma \leq X\leq \mu + 2\sigma\right] \approx 0.95\)</span> — that is, about 95% of observations lie within two standard deviations of the mean.</li>
<li><span class="math inline">\(\mathbb{P}\left[\mu - 3\sigma \leq X\leq \mu + 3\sigma\right] \approx 0.997\)</span> — that is, about 99.7% of observations lie within three standard deviations of the mean.</li>
</ul>
</div>
</div>
<p>For each of the following, assume that <span class="math inline">\(X\sim N\left(\mu = 85, \sigma = 5\right)\)</span>.</p>
<div class="callout callout-style-default callout-caution 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">
Check Your Understanding: The Empirical Rule I
</div>
</div>
<div class="callout-body-container callout-body">
<p>Use the <em>Empirical Rule</em> to approximate <span class="math inline">\(\mathbb{P}\left[80\leq X\leq 90\right]\)</span>.</p>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb3" data-startfrom="365" data-source-offset="-1"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 364;"><span id="cb3-365"><a href="#cb3-365" aria-hidden="true" tabindex="-1"></a>mutable ok_response <span class="op">=</span> (response<span class="op">,</span> n) <span class="kw">=></span> { <span class="cf">return</span> <span class="fu">html</span><span class="vs">`Loading...`</span> }<span class="op">;</span></span>
<span id="cb3-366"><a href="#cb3-366" aria-hidden="true" tabindex="-1"></a>viewof q1 <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">radio</span>(</span>
<span id="cb3-367"><a href="#cb3-367" aria-hidden="true" tabindex="-1"></a> <span class="kw">new</span> <span class="bu">Map</span>([</span>
<span id="cb3-368"><a href="#cb3-368" aria-hidden="true" tabindex="-1"></a> [<span class="st">"50%"</span><span class="op">,</span> <span class="dv">1</span>]<span class="op">,</span></span>
<span id="cb3-369"><a href="#cb3-369" aria-hidden="true" tabindex="-1"></a> [<span class="st">"68%"</span><span class="op">,</span> <span class="dv">2</span>]<span class="op">,</span></span>
<span id="cb3-370"><a href="#cb3-370" aria-hidden="true" tabindex="-1"></a> [<span class="st">"95%"</span><span class="op">,</span> <span class="dv">3</span>]<span class="op">,</span></span>
<span id="cb3-371"><a href="#cb3-371" aria-hidden="true" tabindex="-1"></a> [<span class="st">"Nearly 100%"</span><span class="op">,</span> <span class="dv">4</span>]<span class="op">,</span></span>
<span id="cb3-372"><a href="#cb3-372" aria-hidden="true" tabindex="-1"></a> [<span class="st">"It is impossible to tell"</span><span class="op">,</span> <span class="dv">5</span>]</span>
<span id="cb3-373"><a href="#cb3-373" aria-hidden="true" tabindex="-1"></a> ])<span class="op">,</span></span>
<span id="cb3-374"><a href="#cb3-374" aria-hidden="true" tabindex="-1"></a> {<span class="dt">value</span><span class="op">:</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">parse</span>(localStorage<span class="op">.</span><span class="fu">getItem</span>(<span class="st">"q1_selected_t6d"</span>) <span class="op">??</span> <span class="st">"null"</span>)}</span>
<span id="cb3-375"><a href="#cb3-375" aria-hidden="true" tabindex="-1"></a>)<span class="op">;</span></span>
<span id="cb3-376"><a href="#cb3-376" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-377"><a href="#cb3-377" aria-hidden="true" tabindex="-1"></a>{</span>
<span id="cb3-378"><a href="#cb3-378" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q1_selected_t6d"</span><span class="op">,</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">stringify</span>(q1))<span class="op">;</span></span>
<span id="cb3-379"><a href="#cb3-379" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q1_correct_t6d"</span><span class="op">,</span> <span class="st">"2"</span>)<span class="op">;</span></span>
<span id="cb3-380"><a href="#cb3-380" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q1_result_t6d"</span><span class="op">,</span> q1 <span class="op">===</span> <span class="kw">null</span> <span class="op">?</span> <span class="st">"unattempted"</span> <span class="op">:</span> (q1 <span class="op">==</span> <span class="dv">2</span> <span class="op">?</span> <span class="st">"correct"</span> <span class="op">:</span> <span class="st">"incorrect"</span>))<span class="op">;</span></span>
<span id="cb3-381"><a href="#cb3-381" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-3-1" data-nodetype="declaration">
</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-3-2" data-nodetype="declaration">
</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-3-3" data-nodetype="expression">
</div>
</div>
</div>
<div class="sourceCode cell-code hidden" id="cb4" data-startfrom="382" data-source-offset="-520"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 381;"><span id="cb4-382"><a href="#cb4-382" aria-hidden="true" tabindex="-1"></a><span class="fu">ok_response</span>(q1<span class="op">,</span> <span class="st">"2"</span>)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-3-4" data-nodetype="expression">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="callout callout-style-default callout-caution 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">
Check Your Understanding: The Empirical Rule II
</div>
</div>
<div class="callout-body-container callout-body">
<p>According to the <em>Empirical Rule</em>, which of the following are boundary values for which we expect about 95% of observed values of <span class="math inline">\(X\)</span> to fall between?</p>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb5" data-startfrom="395" data-source-offset="-1"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 394;"><span id="cb5-395"><a href="#cb5-395" aria-hidden="true" tabindex="-1"></a>viewof q2 <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">checkbox</span>(</span>
<span id="cb5-396"><a href="#cb5-396" aria-hidden="true" tabindex="-1"></a> <span class="kw">new</span> <span class="bu">Map</span>([</span>
<span id="cb5-397"><a href="#cb5-397" aria-hidden="true" tabindex="-1"></a> [<span class="st">"0"</span><span class="op">,</span> <span class="dv">1</span>]<span class="op">,</span></span>
<span id="cb5-398"><a href="#cb5-398" aria-hidden="true" tabindex="-1"></a> [<span class="st">"50"</span><span class="op">,</span> <span class="dv">2</span>]<span class="op">,</span></span>
<span id="cb5-399"><a href="#cb5-399" aria-hidden="true" tabindex="-1"></a> [<span class="st">"75"</span><span class="op">,</span> <span class="dv">3</span>]<span class="op">,</span></span>
<span id="cb5-400"><a href="#cb5-400" aria-hidden="true" tabindex="-1"></a> [<span class="st">"80"</span><span class="op">,</span> <span class="dv">4</span>]<span class="op">,</span></span>
<span id="cb5-401"><a href="#cb5-401" aria-hidden="true" tabindex="-1"></a> [<span class="st">"90"</span><span class="op">,</span> <span class="dv">5</span>]<span class="op">,</span></span>
<span id="cb5-402"><a href="#cb5-402" aria-hidden="true" tabindex="-1"></a> [<span class="st">"95"</span><span class="op">,</span> <span class="dv">6</span>]<span class="op">,</span></span>
<span id="cb5-403"><a href="#cb5-403" aria-hidden="true" tabindex="-1"></a> [<span class="st">"100"</span><span class="op">,</span> <span class="dv">7</span>]</span>
<span id="cb5-404"><a href="#cb5-404" aria-hidden="true" tabindex="-1"></a> ])<span class="op">,</span></span>
<span id="cb5-405"><a href="#cb5-405" aria-hidden="true" tabindex="-1"></a> {<span class="dt">value</span><span class="op">:</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">parse</span>(localStorage<span class="op">.</span><span class="fu">getItem</span>(<span class="st">"q2_selected_t6d"</span>) <span class="op">??</span> <span class="st">"[]"</span>) <span class="op">??</span> []}</span>
<span id="cb5-406"><a href="#cb5-406" aria-hidden="true" tabindex="-1"></a>)<span class="op">;</span></span>
<span id="cb5-407"><a href="#cb5-407" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-408"><a href="#cb5-408" aria-hidden="true" tabindex="-1"></a>{</span>
<span id="cb5-409"><a href="#cb5-409" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q2_selected_t6d"</span><span class="op">,</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">stringify</span>(q2))<span class="op">;</span></span>
<span id="cb5-410"><a href="#cb5-410" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q2_correct_t6d"</span><span class="op">,</span> <span class="st">"3,6"</span>)<span class="op">;</span></span>
<span id="cb5-411"><a href="#cb5-411" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q2_result_t6d"</span><span class="op">,</span> (<span class="op">!</span>q2 <span class="op">||</span> q2<span class="op">.</span><span class="at">length</span> <span class="op">===</span> <span class="dv">0</span>) <span class="op">?</span> <span class="st">"unattempted"</span> <span class="op">:</span> (q2<span class="op">.</span><span class="fu">toString</span>() <span class="op">===</span> <span class="st">"3,6"</span> <span class="op">?</span> <span class="st">"correct"</span> <span class="op">:</span> <span class="st">"incorrect"</span>))<span class="op">;</span></span>
<span id="cb5-412"><a href="#cb5-412" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-4-1" data-nodetype="declaration">
</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-4-2" data-nodetype="expression">
</div>
</div>
</div>
<div class="sourceCode cell-code hidden" id="cb6" data-startfrom="413" data-source-offset="-486"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 412;"><span id="cb6-413"><a href="#cb6-413" aria-hidden="true" tabindex="-1"></a><span class="fu">ok_checkbox</span>(q2<span class="op">.</span><span class="fu">toString</span>()<span class="op">,</span> <span class="st">"3,6"</span>)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-4-3" data-nodetype="expression">
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="standardization-and-z-scores" class="level2">
<h2 class="anchored" data-anchor-id="standardization-and-z-scores">Standardization and <span class="math inline">\(z\)</span>-Scores</h2>
<p><strong>Scenario:</strong> Two students, Bob and Sally, are trying to compare how well they did on a college entrance exam. The difficulty comes in that Bob took the SAT which is known to follow an approximate normal distribution with a mean score of 1068 and a standard deviation of 210, while Sally took the ACT which also follows an approximately normal distribution but with a mean score of 20.8 and a standard deviation of 5.8. If Bob scored a 1400 on the SAT and Sally scored a 31 on the ACT, who scored relatively higher?</p>
<p>How do we answer this question? We’ll see two methods.</p>
<p><strong>Method 1:</strong> We can standardize the test scores so that they have comparable units.</p>
<p><strong>Definition (z-score):</strong> If an observation <span class="math inline">\(x\)</span> comes from a nearly normal population with mean <span class="math inline">\(\mu\)</span> and standard deviation <span class="math inline">\(\sigma\)</span>, then we compute the <strong><em><span class="math inline">\(z\)</span>-score</em></strong> associated with <span class="math inline">\(x\)</span> as follows:</p>
<p><span class="math display">\[\displaystyle{z = \frac{x - \mu}{\sigma}}\]</span></p>
<p>An observation’s <span class="math inline">\(z\)</span>-score is simply the number of standard deviations it falls above or below the mean.</p>
<p>Use the code block below to compute Bob and Sally’s <span class="math inline">\(z\)</span>-scores and answer the questions that follow.</p>
<div class="cell" data-exercise="compute-z-scores">
<div>
<div id="webr-4" class="exercise-cell">
</div>
<script type="webr-4-contents">
eyJjb2RlIjoiIyBVc2UgdGhpcyBjb2RlIGJsb2NrIGZvciBzY3JhdGNoIHdvcmsiLCJhdHRyIjp7ImV2YWwiOnRydWUsImVkaXQiOnRydWUsInBlcnNpc3QiOnRydWUsImV4ZXJjaXNlIjoiY29tcHV0ZS16LXNjb3JlcyJ9fQ==
</script>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-6-contents" aria-controls="callout-6" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 1
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-6" class="callout-6-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Use the <span class="math inline">\(z\)</span>-score formula above: <span class="math inline">\((x - \mu) / \sigma\)</span>.</p>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-7-contents" aria-controls="callout-7" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 2
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-7" class="callout-7-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Fill in the blanks:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>(___ <span class="sc">-</span> ___) <span class="sc">/</span> ___</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-8-contents" aria-controls="callout-8" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 3
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-8" class="callout-8-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Bob took the SAT exam, where the mean score (<span class="math inline">\(\mu\)</span>) was 1068.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>(___ <span class="sc">-</span> <span class="dv">1068</span>) <span class="sc">/</span> ___</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-9-contents" aria-controls="callout-9" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 4
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-9" class="callout-9-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>The standard deviation (<span class="math inline">\(\sigma\)</span>) on the SAT exam was 210.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>(___ <span class="sc">-</span> <span class="dv">1068</span>) <span class="sc">/</span> <span class="dv">210</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-10-contents" aria-controls="callout-10" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 5
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-10" class="callout-10-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Bob’s score on the SAT exam was 1400.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>(<span class="dv">1400</span> <span class="sc">-</span> <span class="dv">1068</span>) <span class="sc">/</span> <span class="dv">210</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-11-contents" aria-controls="callout-11" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 6
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-11" class="callout-11-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Now do the same for Sally, but be sure to use the mean (<span class="math inline">\(\mu\)</span>) and standard deviation (<span class="math inline">\(\sigma\)</span>) from the ACT exam, since that’s the exam she completed.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Bob</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a>(<span class="dv">1400</span> <span class="sc">-</span> <span class="dv">1068</span>) <span class="sc">/</span> <span class="dv">210</span></span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Sally</span></span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>(___ <span class="sc">-</span> ___) <span class="sc">/</span> ___</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-12-contents" aria-controls="callout-12" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 7
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-12" class="callout-12-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>The average score for the ACT was 20.8.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Bob</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>(<span class="dv">1400</span> <span class="sc">-</span> <span class="dv">1068</span>) <span class="sc">/</span> <span class="dv">210</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Sally</span></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>(___ <span class="sc">-</span> <span class="fl">20.8</span>) <span class="sc">/</span> ___</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-13-contents" aria-controls="callout-13" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 8
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-13" class="callout-13-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>The standard deviation in ACT scores was 5.8.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Bob</span></span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>(<span class="dv">1400</span> <span class="sc">-</span> <span class="dv">1068</span>) <span class="sc">/</span> <span class="dv">210</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Sally</span></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a>(___ <span class="sc">-</span> <span class="fl">20.8</span>) <span class="sc">/</span> <span class="fl">5.8</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-z-scores">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-14-contents" aria-controls="callout-14" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 9 (Solved)
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-14" class="callout-14-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Sally’s score on the ACT was 31.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Bob</span></span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>(<span class="dv">1400</span> <span class="sc">-</span> <span class="dv">1068</span>) <span class="sc">/</span> <span class="dv">210</span></span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Sally</span></span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a>(<span class="dv">31</span> <span class="sc">-</span> <span class="fl">20.8</span>) <span class="sc">/</span> <span class="fl">5.8</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="callout callout-style-default callout-caution 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">
Check Your Understanding: <span class="math inline">\(z\)</span>-Scores I
</div>
</div>
<div class="callout-body-container callout-body">
<p>Which of the following is the <span class="math inline">\(z\)</span>-score corresponding to Bob? (round to two decimal places)</p>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb15" data-startfrom="601" data-source-offset="-1"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 600;"><span id="cb15-601"><a href="#cb15-601" aria-hidden="true" tabindex="-1"></a>viewof q3 <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">radio</span>(</span>
<span id="cb15-602"><a href="#cb15-602" aria-hidden="true" tabindex="-1"></a> <span class="kw">new</span> <span class="bu">Map</span>([</span>
<span id="cb15-603"><a href="#cb15-603" aria-hidden="true" tabindex="-1"></a> [<span class="st">"1.58"</span><span class="op">,</span> <span class="dv">1</span>]<span class="op">,</span></span>
<span id="cb15-604"><a href="#cb15-604" aria-hidden="true" tabindex="-1"></a> [<span class="st">"1394.91"</span><span class="op">,</span> <span class="dv">2</span>]<span class="op">,</span></span>
<span id="cb15-605"><a href="#cb15-605" aria-hidden="true" tabindex="-1"></a> [<span class="st">"-1.58"</span><span class="op">,</span> <span class="dv">3</span>]<span class="op">,</span></span>
<span id="cb15-606"><a href="#cb15-606" aria-hidden="true" tabindex="-1"></a> [<span class="st">"1.76"</span><span class="op">,</span> <span class="dv">4</span>]<span class="op">,</span></span>
<span id="cb15-607"><a href="#cb15-607" aria-hidden="true" tabindex="-1"></a> [<span class="st">"-1.76"</span><span class="op">,</span> <span class="dv">5</span>]</span>
<span id="cb15-608"><a href="#cb15-608" aria-hidden="true" tabindex="-1"></a> ])<span class="op">,</span></span>
<span id="cb15-609"><a href="#cb15-609" aria-hidden="true" tabindex="-1"></a> {<span class="dt">value</span><span class="op">:</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">parse</span>(localStorage<span class="op">.</span><span class="fu">getItem</span>(<span class="st">"q3_selected_t6d"</span>) <span class="op">??</span> <span class="st">"null"</span>)}</span>
<span id="cb15-610"><a href="#cb15-610" aria-hidden="true" tabindex="-1"></a>)<span class="op">;</span></span>
<span id="cb15-611"><a href="#cb15-611" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-612"><a href="#cb15-612" aria-hidden="true" tabindex="-1"></a>{</span>
<span id="cb15-613"><a href="#cb15-613" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q3_selected_t6d"</span><span class="op">,</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">stringify</span>(q3))<span class="op">;</span></span>
<span id="cb15-614"><a href="#cb15-614" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q3_correct_t6d"</span><span class="op">,</span> <span class="st">"1"</span>)<span class="op">;</span></span>
<span id="cb15-615"><a href="#cb15-615" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q3_result_t6d"</span><span class="op">,</span> q3 <span class="op">===</span> <span class="kw">null</span> <span class="op">?</span> <span class="st">"unattempted"</span> <span class="op">:</span> (q3 <span class="op">==</span> <span class="dv">1</span> <span class="op">?</span> <span class="st">"correct"</span> <span class="op">:</span> <span class="st">"incorrect"</span>))<span class="op">;</span></span>
<span id="cb15-616"><a href="#cb15-616" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-5-1" data-nodetype="declaration">
</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-5-2" data-nodetype="expression">
</div>
</div>
</div>
<div class="sourceCode cell-code hidden" id="cb16" data-startfrom="617" data-source-offset="-433"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 616;"><span id="cb16-617"><a href="#cb16-617" aria-hidden="true" tabindex="-1"></a><span class="fu">ok_response</span>(q3<span class="op">,</span> <span class="st">"1"</span>)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-5-3" data-nodetype="expression">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="callout callout-style-default callout-caution 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">
Check Your Understanding: <span class="math inline">\(z\)</span>-Scores II
</div>
</div>
<div class="callout-body-container callout-body">
<p>Which of the following is the <span class="math inline">\(z\)</span>-score corresponding to Sally? (round to two decimal places)</p>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb17" data-startfrom="630" data-source-offset="-1"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 629;"><span id="cb17-630"><a href="#cb17-630" aria-hidden="true" tabindex="-1"></a>viewof q4 <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">radio</span>(</span>
<span id="cb17-631"><a href="#cb17-631" aria-hidden="true" tabindex="-1"></a> <span class="kw">new</span> <span class="bu">Map</span>([</span>
<span id="cb17-632"><a href="#cb17-632" aria-hidden="true" tabindex="-1"></a> [<span class="st">"1.58"</span><span class="op">,</span> <span class="dv">1</span>]<span class="op">,</span></span>
<span id="cb17-633"><a href="#cb17-633" aria-hidden="true" tabindex="-1"></a> [<span class="st">"27.41"</span><span class="op">,</span> <span class="dv">2</span>]<span class="op">,</span></span>
<span id="cb17-634"><a href="#cb17-634" aria-hidden="true" tabindex="-1"></a> [<span class="st">"-1.58"</span><span class="op">,</span> <span class="dv">3</span>]<span class="op">,</span></span>
<span id="cb17-635"><a href="#cb17-635" aria-hidden="true" tabindex="-1"></a> [<span class="st">"1.76"</span><span class="op">,</span> <span class="dv">4</span>]<span class="op">,</span></span>
<span id="cb17-636"><a href="#cb17-636" aria-hidden="true" tabindex="-1"></a> [<span class="st">"-1.76"</span><span class="op">,</span> <span class="dv">5</span>]</span>
<span id="cb17-637"><a href="#cb17-637" aria-hidden="true" tabindex="-1"></a> ])<span class="op">,</span></span>
<span id="cb17-638"><a href="#cb17-638" aria-hidden="true" tabindex="-1"></a> {<span class="dt">value</span><span class="op">:</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">parse</span>(localStorage<span class="op">.</span><span class="fu">getItem</span>(<span class="st">"q4_selected_t6d"</span>) <span class="op">??</span> <span class="st">"null"</span>)}</span>
<span id="cb17-639"><a href="#cb17-639" aria-hidden="true" tabindex="-1"></a>)<span class="op">;</span></span>
<span id="cb17-640"><a href="#cb17-640" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-641"><a href="#cb17-641" aria-hidden="true" tabindex="-1"></a>{</span>
<span id="cb17-642"><a href="#cb17-642" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q4_selected_t6d"</span><span class="op">,</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">stringify</span>(q4))<span class="op">;</span></span>
<span id="cb17-643"><a href="#cb17-643" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q4_correct_t6d"</span><span class="op">,</span> <span class="st">"4"</span>)<span class="op">;</span></span>
<span id="cb17-644"><a href="#cb17-644" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q4_result_t6d"</span><span class="op">,</span> q4 <span class="op">===</span> <span class="kw">null</span> <span class="op">?</span> <span class="st">"unattempted"</span> <span class="op">:</span> (q4 <span class="op">==</span> <span class="dv">4</span> <span class="op">?</span> <span class="st">"correct"</span> <span class="op">:</span> <span class="st">"incorrect"</span>))<span class="op">;</span></span>
<span id="cb17-645"><a href="#cb17-645" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-6-1" data-nodetype="declaration">
</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-6-2" data-nodetype="expression">
</div>
</div>
</div>
<div class="sourceCode cell-code hidden" id="cb18" data-startfrom="646" data-source-offset="-431"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 645;"><span id="cb18-646"><a href="#cb18-646" aria-hidden="true" tabindex="-1"></a><span class="fu">ok_response</span>(q4<span class="op">,</span> <span class="st">"4"</span>)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-6-3" data-nodetype="expression">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="callout callout-style-default callout-caution 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">
Check Your Understanding: <span class="math inline">\(z\)</span>-Scores III
</div>
</div>
<div class="callout-body-container callout-body">
<p>Who did relatively better on their standardized exam, Bob or Sally? Why?</p>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb19" data-startfrom="659" data-source-offset="-1"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 658;"><span id="cb19-659"><a href="#cb19-659" aria-hidden="true" tabindex="-1"></a>viewof q5 <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">radio</span>(</span>
<span id="cb19-660"><a href="#cb19-660" aria-hidden="true" tabindex="-1"></a> <span class="kw">new</span> <span class="bu">Map</span>([</span>
<span id="cb19-661"><a href="#cb19-661" aria-hidden="true" tabindex="-1"></a> [<span class="st">"Sally, since her score is 1.76 standard deviations above the mean, while Bob's was only 1.58 standard deviations above the mean."</span><span class="op">,</span> <span class="dv">1</span>]<span class="op">,</span></span>
<span id="cb19-662"><a href="#cb19-662" aria-hidden="true" tabindex="-1"></a> [<span class="st">"Bob, since his z-score was 1.58 which is closer to the mean than Sally's z-score of 1.76."</span><span class="op">,</span> <span class="dv">2</span>]<span class="op">,</span></span>
<span id="cb19-663"><a href="#cb19-663" aria-hidden="true" tabindex="-1"></a> [<span class="st">"Bob, since his score was 1400 and Sally's score was only 31."</span><span class="op">,</span> <span class="dv">3</span>]<span class="op">,</span></span>
<span id="cb19-664"><a href="#cb19-664" aria-hidden="true" tabindex="-1"></a> [<span class="st">"Bob, since the SAT had a larger standard deviation it is a harder exam."</span><span class="op">,</span> <span class="dv">4</span>]</span>
<span id="cb19-665"><a href="#cb19-665" aria-hidden="true" tabindex="-1"></a> ])<span class="op">,</span></span>
<span id="cb19-666"><a href="#cb19-666" aria-hidden="true" tabindex="-1"></a> {<span class="dt">value</span><span class="op">:</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">parse</span>(localStorage<span class="op">.</span><span class="fu">getItem</span>(<span class="st">"q5_selected_t6d"</span>) <span class="op">??</span> <span class="st">"null"</span>)}</span>
<span id="cb19-667"><a href="#cb19-667" aria-hidden="true" tabindex="-1"></a>)<span class="op">;</span></span>
<span id="cb19-668"><a href="#cb19-668" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-669"><a href="#cb19-669" aria-hidden="true" tabindex="-1"></a>{</span>
<span id="cb19-670"><a href="#cb19-670" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q5_selected_t6d"</span><span class="op">,</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">stringify</span>(q5))<span class="op">;</span></span>
<span id="cb19-671"><a href="#cb19-671" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q5_correct_t6d"</span><span class="op">,</span> <span class="st">"1"</span>)<span class="op">;</span></span>
<span id="cb19-672"><a href="#cb19-672" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q5_result_t6d"</span><span class="op">,</span> q5 <span class="op">===</span> <span class="kw">null</span> <span class="op">?</span> <span class="st">"unattempted"</span> <span class="op">:</span> (q5 <span class="op">==</span> <span class="dv">1</span> <span class="op">?</span> <span class="st">"correct"</span> <span class="op">:</span> <span class="st">"incorrect"</span>))<span class="op">;</span></span>
<span id="cb19-673"><a href="#cb19-673" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-7-1" data-nodetype="declaration">
</div>
</div>
</div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-7-2" data-nodetype="expression">
</div>
</div>
</div>
<div class="sourceCode cell-code hidden" id="cb20" data-startfrom="674" data-source-offset="-743"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 673;"><span id="cb20-674"><a href="#cb20-674" aria-hidden="true" tabindex="-1"></a><span class="fu">ok_response</span>(q5<span class="op">,</span> <span class="st">"1"</span>)<span class="op">;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-7-3" data-nodetype="expression">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="callout callout-style-default callout-tip 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">
A Recap on <span class="math inline">\(z\)</span>-Scores
</div>
</div>
<div class="callout-body-container callout-body">
<p>We can use <span class="math inline">\(z\)</span>-scores as a common unit for comparing observations from completely different populations (such as SAT scores and ACT scores). Here’s a recap of the most important information so far:</p>
<ul>
<li>If an observation <span class="math inline">\(x\)</span> comes from a nearly normal population with mean <span class="math inline">\(\mu\)</span> and standard deviation <span class="math inline">\(\sigma\)</span>, we can compute its <span class="math inline">\(z\)</span>-score using the formula: <span class="math inline">\(\displaystyle{z = \frac{x - \mu}{\sigma}}\)</span>.</li>
<li>A <span class="math inline">\(z\)</span>-score measures the number of standard deviations which an observation falls above or below the mean.
<ul>
<li>A positive <span class="math inline">\(z\)</span>-score means that an observation was above the mean.</li>
<li>A negative <span class="math inline">\(z\)</span>-score means that an observation was below the mean.</li>
<li>The larger a <span class="math inline">\(z\)</span>-score is in absolute value, the further the corresponding observation falls from the mean.</li>
</ul></li>
</ul>
</div>
</div>
<p><strong>Method 2:</strong> We can compute the <em>percentile</em> corresponding to Bob’s SAT score and the <em>percentile</em> corresponding to Sally’s ACT score.</p>
<p><strong>Definition (percentile):</strong> Given an observation <span class="math inline">\(x\)</span> from a population, the <strong><em>percentile</em></strong> corresponding to <span class="math inline">\(x\)</span> is the proportion of the population which falls at or below <span class="math inline">\(x\)</span>.</p>
<p>In the images below, Bob’s percentile is shown as the shaded area in the distribution on the left, while Sally’s is shown in the distribution on the right.</p>
<div class="columns">
<div class="column" style="width:50%;">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="06_NormalDistributions_Dynamic_files/figure-html/unnamed-chunk-26-1.png" class="img-fluid figure-img" width="288"></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:50%;">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure">
<p><img src="06_NormalDistributions_Dynamic_files/figure-html/unnamed-chunk-27-1.png" class="img-fluid figure-img" width="288"></p>
</figure>
</div>
</div>
</div>
</div>
</div>
<p>There are many ways to compute percentiles. Before the widespread availability of statistical software, people converted observed values to <span class="math inline">\(z\)</span>-scores and then looked up the percentile in a table. Luckily R provides nice functionality for computing percentiles.</p>
<div class="callout callout-style-default callout-tip 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">
Computing Percentiles in R
</div>
</div>
<div class="callout-body-container callout-body">
<p>If <span class="math inline">\(X\sim N\left(\mu, \sigma\right)\)</span>, then <span class="math display">\[\mathbb{P}\left[X\leq q\right] \approx \tt{pnorm(q, mean = \mu, sd = \sigma)}\]</span></p>
</div>
</div>
<p>The block below is preset to compute Bob’s percentile. Execute the code cell and then adapt the code to find Sally’s percentile. Use your results to answer the questions below.</p>
<div class="cell" data-exercise="compute-percentiles">
<div>
<div id="webr-5" class="exercise-cell">
</div>
<script type="webr-5-contents">
eyJjb2RlIjoiXG5wbm9ybSgxNDAwLCAxMDY4LCAyMTApIiwiYXR0ciI6eyJldmFsIjp0cnVlLCJlZGl0Ijp0cnVlLCJwZXJzaXN0Ijp0cnVlLCJleGVyY2lzZSI6ImNvbXB1dGUtcGVyY2VudGlsZXMifX0=
</script>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-percentiles">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-20-contents" aria-controls="callout-20" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 1
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-20" class="callout-20-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Run this code to compute Bob’s percentile, then adapt it for Sally.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a><span class="fu">pnorm</span>(<span class="dv">1400</span>, <span class="dv">1068</span>, <span class="dv">210</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-percentiles">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-21-contents" aria-controls="callout-21" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 2
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-21" class="callout-21-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>The arguments for <code>pnorm()</code> are, in order: the boundary value, the distribution mean (<span class="math inline">\(\mu\)</span>), and the distribution standard deviation (<span class="math inline">\(\sigma\)</span>).</p>
</div>
</div>
</div>
</div>
<div class="hint webr-ojs-exercise exercise-hint d-none" data-exercise="compute-percentiles">
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-22-contents" aria-controls="callout-22" aria-expanded="true" aria-label="Toggle callout">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
Hint 3
</div>
<div class="callout-btn-toggle d-inline-block border-0 py-1 ps-1 pe-0 float-end"><i class="callout-toggle"></i></div>
</div>
<div id="callout-22" class="callout-22-contents callout-collapse collapse show">
<div class="callout-body-container callout-body">
<p>Fill in the blanks using Sally’s ACT score, the mean ACT score, and the standard deviation in ACT scores.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Bob</span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a><span class="fu">pnorm</span>(<span class="dv">1400</span>, <span class="dv">1068</span>, <span class="dv">210</span>)</span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Sally</span></span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a><span class="fu">pnorm</span>(___, ___, ___)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="callout callout-style-default callout-caution 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">
Check Your Understanding: Percentiles I
</div>
</div>
<div class="callout-body-container callout-body">
<p>Which of the following is the percentile corresponding to Bob? (round to four decimal places)</p>
<div class="cell">
<div class="sourceCode cell-code hidden" id="cb23" data-startfrom="821" data-source-offset="-1"><pre class="sourceCode js code-with-copy"><code class="sourceCode javascript" style="counter-reset: source-line 820;"><span id="cb23-821"><a href="#cb23-821" aria-hidden="true" tabindex="-1"></a>viewof q6 <span class="op">=</span> Inputs<span class="op">.</span><span class="fu">radio</span>(</span>
<span id="cb23-822"><a href="#cb23-822" aria-hidden="true" tabindex="-1"></a> <span class="kw">new</span> <span class="bu">Map</span>([</span>
<span id="cb23-823"><a href="#cb23-823" aria-hidden="true" tabindex="-1"></a> [<span class="st">"0.9431"</span><span class="op">,</span> <span class="dv">1</span>]<span class="op">,</span></span>
<span id="cb23-824"><a href="#cb23-824" aria-hidden="true" tabindex="-1"></a> [<span class="st">"0.0569"</span><span class="op">,</span> <span class="dv">2</span>]<span class="op">,</span></span>
<span id="cb23-825"><a href="#cb23-825" aria-hidden="true" tabindex="-1"></a> [<span class="st">"0.4431"</span><span class="op">,</span> <span class="dv">3</span>]<span class="op">,</span></span>
<span id="cb23-826"><a href="#cb23-826" aria-hidden="true" tabindex="-1"></a> [<span class="st">"0.9608"</span><span class="op">,</span> <span class="dv">4</span>]<span class="op">,</span></span>
<span id="cb23-827"><a href="#cb23-827" aria-hidden="true" tabindex="-1"></a> [<span class="st">"0.0392"</span><span class="op">,</span> <span class="dv">5</span>]</span>
<span id="cb23-828"><a href="#cb23-828" aria-hidden="true" tabindex="-1"></a> ])<span class="op">,</span></span>
<span id="cb23-829"><a href="#cb23-829" aria-hidden="true" tabindex="-1"></a> {<span class="dt">value</span><span class="op">:</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">parse</span>(localStorage<span class="op">.</span><span class="fu">getItem</span>(<span class="st">"q6_selected_t6d"</span>) <span class="op">??</span> <span class="st">"null"</span>)}</span>
<span id="cb23-830"><a href="#cb23-830" aria-hidden="true" tabindex="-1"></a>)<span class="op">;</span></span>
<span id="cb23-831"><a href="#cb23-831" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb23-832"><a href="#cb23-832" aria-hidden="true" tabindex="-1"></a>{</span>
<span id="cb23-833"><a href="#cb23-833" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q6_selected_t6d"</span><span class="op">,</span> <span class="bu">JSON</span><span class="op">.</span><span class="fu">stringify</span>(q6))<span class="op">;</span></span>
<span id="cb23-834"><a href="#cb23-834" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q6_correct_t6d"</span><span class="op">,</span> <span class="st">"1"</span>)<span class="op">;</span></span>
<span id="cb23-835"><a href="#cb23-835" aria-hidden="true" tabindex="-1"></a> localStorage<span class="op">.</span><span class="fu">setItem</span>(<span class="st">"q6_result_t6d"</span><span class="op">,</span> q6 <span class="op">===</span> <span class="kw">null</span> <span class="op">?</span> <span class="st">"unattempted"</span> <span class="op">:</span> (q6 <span class="op">==</span> <span class="dv">1</span> <span class="op">?</span> <span class="st">"correct"</span> <span class="op">:</span> <span class="st">"incorrect"</span>))<span class="op">;</span></span>
<span id="cb23-836"><a href="#cb23-836" aria-hidden="true" tabindex="-1"></a>}</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-display">
<div>
<div id="ojs-cell-8-1" data-nodetype="declaration">