-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstats.html
More file actions
1071 lines (983 loc) · 86.6 KB
/
stats.html
File metadata and controls
1071 lines (983 loc) · 86.6 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 lang="" xml:lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Chapter 5 Introduction to Basic Statistics | Hydroinformatics at VT</title>
<meta name="description" content="This bookdown contains notes and exercises for a course in hydroinformatics at Virginia Tech." />
<meta name="generator" content="bookdown 0.27 and GitBook 2.6.7" />
<meta property="og:title" content="Chapter 5 Introduction to Basic Statistics | Hydroinformatics at VT" />
<meta property="og:type" content="book" />
<meta property="og:description" content="This bookdown contains notes and exercises for a course in hydroinformatics at Virginia Tech." />
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="Chapter 5 Introduction to Basic Statistics | Hydroinformatics at VT" />
<meta name="twitter:description" content="This bookdown contains notes and exercises for a course in hydroinformatics at Virginia Tech." />
<meta name="author" content="JP Gannon" />
<meta name="date" content="2023-02-09" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="prev" href="introactivity.html"/>
<link rel="next" href="statsactivity.html"/>
<script src="libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js@6.4.6/dist/fuse.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-clipboard.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections.css" rel="stylesheet" />
<link href="libs/anchor-sections-1.1.0/anchor-sections-hash.css" rel="stylesheet" />
<script src="libs/anchor-sections-1.1.0/anchor-sections.js"></script>
<script src="libs/htmlwidgets-1.5.4/htmlwidgets.js"></script>
<link href="libs/leaflet-1.3.1/leaflet.css" rel="stylesheet" />
<script src="libs/leaflet-1.3.1/leaflet.js"></script>
<link href="libs/leafletfix-1.0.0/leafletfix.css" rel="stylesheet" />
<script src="libs/proj4-2.6.2/proj4.min.js"></script>
<script src="libs/Proj4Leaflet-1.0.1/proj4leaflet.js"></script>
<link href="libs/rstudio_leaflet-1.3.1/rstudio_leaflet.css" rel="stylesheet" />
<script src="libs/leaflet-binding-2.1.1/leaflet.js"></script>
<script src="libs/leaflet-providers-1.9.0/leaflet-providers_1.9.0.js"></script>
<script src="libs/leaflet-providers-plugin-2.1.1/leaflet-providers-plugin.js"></script>
<script src="libs/rglWebGL-binding-0.109.6/rglWebGL.js"></script>
<link href="libs/rglwidgetClass-0.109.6/rgl.css" rel="stylesheet" />
<script src="libs/rglwidgetClass-0.109.6/rglClass.min.js"></script>
<script type = "text/plain" id = "rgl-vertex-shader">
#line 2 1
// File 1 is the vertex shader
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
attribute vec3 aPos;
attribute vec4 aCol;
uniform mat4 mvMatrix;
uniform mat4 prMatrix;
varying vec4 vCol;
varying vec4 vPosition;
#ifdef NEEDS_VNORMAL
attribute vec3 aNorm;
uniform mat4 normMatrix;
varying vec4 vNormal;
#endif
#if defined(HAS_TEXTURE) || defined (IS_TEXT)
attribute vec2 aTexcoord;
varying vec2 vTexcoord;
#endif
#ifdef FIXED_SIZE
uniform vec3 textScale;
#endif
#ifdef FIXED_QUADS
attribute vec3 aOfs;
#endif
#ifdef IS_TWOSIDED
#ifdef HAS_NORMALS
varying float normz;
uniform mat4 invPrMatrix;
#else
attribute vec3 aPos1;
attribute vec3 aPos2;
varying float normz;
#endif
#endif // IS_TWOSIDED
#ifdef FAT_LINES
attribute vec3 aNext;
attribute vec2 aPoint;
varying vec2 vPoint;
varying float vLength;
uniform float uAspect;
uniform float uLwd;
#endif
void main(void) {
#ifndef IS_BRUSH
#if defined(NCLIPPLANES) || !defined(FIXED_QUADS) || defined(HAS_FOG)
vPosition = mvMatrix * vec4(aPos, 1.);
#endif
#ifndef FIXED_QUADS
gl_Position = prMatrix * vPosition;
#endif
#endif // !IS_BRUSH
#ifdef IS_POINTS
gl_PointSize = POINTSIZE;
#endif
vCol = aCol;
#ifdef NEEDS_VNORMAL
vNormal = normMatrix * vec4(-aNorm, dot(aNorm, aPos));
#endif
#ifdef IS_TWOSIDED
#ifdef HAS_NORMALS
/* normz should be calculated *after* projection */
normz = (invPrMatrix*vNormal).z;
#else
vec4 pos1 = prMatrix*(mvMatrix*vec4(aPos1, 1.));
pos1 = pos1/pos1.w - gl_Position/gl_Position.w;
vec4 pos2 = prMatrix*(mvMatrix*vec4(aPos2, 1.));
pos2 = pos2/pos2.w - gl_Position/gl_Position.w;
normz = pos1.x*pos2.y - pos1.y*pos2.x;
#endif
#endif // IS_TWOSIDED
#ifdef NEEDS_VNORMAL
vNormal = vec4(normalize(vNormal.xyz/vNormal.w), 1);
#endif
#if defined(HAS_TEXTURE) || defined(IS_TEXT)
vTexcoord = aTexcoord;
#endif
#if defined(FIXED_SIZE) && !defined(ROTATING)
vec4 pos = prMatrix * mvMatrix * vec4(aPos, 1.);
pos = pos/pos.w;
gl_Position = pos + vec4(aOfs*textScale, 0.);
#endif
#if defined(IS_SPRITES) && !defined(FIXED_SIZE)
vec4 pos = mvMatrix * vec4(aPos, 1.);
pos = pos/pos.w + vec4(aOfs, 0.);
gl_Position = prMatrix*pos;
#endif
#ifdef FAT_LINES
/* This code was inspired by Matt Deslauriers' code in
https://mattdesl.svbtle.com/drawing-lines-is-hard */
vec2 aspectVec = vec2(uAspect, 1.0);
mat4 projViewModel = prMatrix * mvMatrix;
vec4 currentProjected = projViewModel * vec4(aPos, 1.0);
currentProjected = currentProjected/currentProjected.w;
vec4 nextProjected = projViewModel * vec4(aNext, 1.0);
vec2 currentScreen = currentProjected.xy * aspectVec;
vec2 nextScreen = (nextProjected.xy / nextProjected.w) * aspectVec;
float len = uLwd;
vec2 dir = vec2(1.0, 0.0);
vPoint = aPoint;
vLength = length(nextScreen - currentScreen)/2.0;
vLength = vLength/(vLength + len);
if (vLength > 0.0) {
dir = normalize(nextScreen - currentScreen);
}
vec2 normal = vec2(-dir.y, dir.x);
dir.x /= uAspect;
normal.x /= uAspect;
vec4 offset = vec4(len*(normal*aPoint.x*aPoint.y - dir), 0.0, 0.0);
gl_Position = currentProjected + offset;
#endif
#ifdef IS_BRUSH
gl_Position = vec4(aPos, 1.);
#endif
}
</script>
<script type = "text/plain" id = "rgl-fragment-shader">
#line 2 2
// File 2 is the fragment shader
#ifdef GL_ES
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
#endif
varying vec4 vCol; // carries alpha
varying vec4 vPosition;
#if defined(HAS_TEXTURE) || defined (IS_TEXT)
varying vec2 vTexcoord;
uniform sampler2D uSampler;
#endif
#ifdef HAS_FOG
uniform int uFogMode;
uniform vec3 uFogColor;
uniform vec4 uFogParms;
#endif
#if defined(IS_LIT) && !defined(FIXED_QUADS)
varying vec4 vNormal;
#endif
#if NCLIPPLANES > 0
uniform vec4 vClipplane[NCLIPPLANES];
#endif
#if NLIGHTS > 0
uniform mat4 mvMatrix;
#endif
#ifdef IS_LIT
uniform vec3 emission;
uniform float shininess;
#if NLIGHTS > 0
uniform vec3 ambient[NLIGHTS];
uniform vec3 specular[NLIGHTS]; // light*material
uniform vec3 diffuse[NLIGHTS];
uniform vec3 lightDir[NLIGHTS];
uniform bool viewpoint[NLIGHTS];
uniform bool finite[NLIGHTS];
#endif
#endif // IS_LIT
#ifdef IS_TWOSIDED
uniform bool front;
varying float normz;
#endif
#ifdef FAT_LINES
varying vec2 vPoint;
varying float vLength;
#endif
void main(void) {
vec4 fragColor;
#ifdef FAT_LINES
vec2 point = vPoint;
bool neg = point.y < 0.0;
point.y = neg ? (point.y + vLength)/(1.0 - vLength) :
-(point.y - vLength)/(1.0 - vLength);
#if defined(IS_TRANSPARENT) && defined(IS_LINESTRIP)
if (neg && length(point) <= 1.0) discard;
#endif
point.y = min(point.y, 0.0);
if (length(point) > 1.0) discard;
#endif // FAT_LINES
#ifdef ROUND_POINTS
vec2 coord = gl_PointCoord - vec2(0.5);
if (length(coord) > 0.5) discard;
#endif
#if NCLIPPLANES > 0
for (int i = 0; i < NCLIPPLANES; i++)
if (dot(vPosition, vClipplane[i]) < 0.0) discard;
#endif
#ifdef FIXED_QUADS
vec3 n = vec3(0., 0., 1.);
#elif defined(IS_LIT)
vec3 n = normalize(vNormal.xyz);
#endif
#ifdef IS_TWOSIDED
if ((normz <= 0.) != front) discard;
#endif
#ifdef IS_LIT
vec3 eye = normalize(-vPosition.xyz/vPosition.w);
vec3 lightdir;
vec4 colDiff;
vec3 halfVec;
vec4 lighteffect = vec4(emission, 0.);
vec3 col;
float nDotL;
#ifdef FIXED_QUADS
n = -faceforward(n, n, eye);
#endif
#if NLIGHTS > 0
for (int i=0;i<NLIGHTS;i++) {
colDiff = vec4(vCol.rgb * diffuse[i], vCol.a);
lightdir = lightDir[i];
if (!viewpoint[i])
lightdir = (mvMatrix * vec4(lightdir, 1.)).xyz;
if (!finite[i]) {
halfVec = normalize(lightdir + eye);
} else {
lightdir = normalize(lightdir - vPosition.xyz/vPosition.w);
halfVec = normalize(lightdir + eye);
}
col = ambient[i];
nDotL = dot(n, lightdir);
col = col + max(nDotL, 0.) * colDiff.rgb;
col = col + pow(max(dot(halfVec, n), 0.), shininess) * specular[i];
lighteffect = lighteffect + vec4(col, colDiff.a);
}
#endif
#else // not IS_LIT
vec4 colDiff = vCol;
vec4 lighteffect = colDiff;
#endif
#ifdef IS_TEXT
vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);
#endif
#ifdef HAS_TEXTURE
#ifdef TEXTURE_rgb
vec4 textureColor = lighteffect*vec4(texture2D(uSampler, vTexcoord).rgb, 1.);
#endif
#ifdef TEXTURE_rgba
vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);
#endif
#ifdef TEXTURE_alpha
vec4 textureColor = texture2D(uSampler, vTexcoord);
float luminance = dot(vec3(1.,1.,1.), textureColor.rgb)/3.;
textureColor = vec4(lighteffect.rgb, lighteffect.a*luminance);
#endif
#ifdef TEXTURE_luminance
vec4 textureColor = vec4(lighteffect.rgb*dot(texture2D(uSampler, vTexcoord).rgb, vec3(1.,1.,1.))/3., lighteffect.a);
#endif
#ifdef TEXTURE_luminance_alpha
vec4 textureColor = texture2D(uSampler, vTexcoord);
float luminance = dot(vec3(1.,1.,1.),textureColor.rgb)/3.;
textureColor = vec4(lighteffect.rgb*luminance, lighteffect.a*textureColor.a);
#endif
fragColor = textureColor;
#elif defined(IS_TEXT)
if (textureColor.a < 0.1)
discard;
else
fragColor = textureColor;
#else
fragColor = lighteffect;
#endif // HAS_TEXTURE
#ifdef HAS_FOG
// uFogParms elements: x = near, y = far, z = fogscale, w = (1-sin(FOV/2))/(1+sin(FOV/2))
// In Exp and Exp2: use density = density/far
// fogF will be the proportion of fog
// Initialize it to the linear value
float fogF;
if (uFogMode > 0) {
fogF = (uFogParms.y - vPosition.z/vPosition.w)/(uFogParms.y - uFogParms.x);
if (uFogMode > 1)
fogF = mix(uFogParms.w, 1.0, fogF);
fogF = fogF*uFogParms.z;
if (uFogMode == 2)
fogF = 1.0 - exp(-fogF);
// Docs are wrong: use (density*c)^2, not density*c^2
// https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/src/mesa/swrast/s_fog.c#L58
else if (uFogMode == 3)
fogF = 1.0 - exp(-fogF*fogF);
fogF = clamp(fogF, 0.0, 1.0);
gl_FragColor = vec4(mix(fragColor.rgb, uFogColor, fogF), fragColor.a);
} else gl_FragColor = fragColor;
#else
gl_FragColor = fragColor;
#endif // HAS_FOG
}
</script>
<script src="libs/CanvasMatrix4-0.109.6/CanvasMatrix.min.js"></script>
<script src="libs/plotly-binding-4.10.0/plotly.js"></script>
<script src="libs/typedarray-0.1/typedarray.min.js"></script>
<link href="libs/crosstalk-1.2.0/css/crosstalk.min.css" rel="stylesheet" />
<script src="libs/crosstalk-1.2.0/js/crosstalk.min.js"></script>
<link href="libs/plotly-htmlwidgets-css-2.5.1/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="libs/plotly-main-2.5.1/plotly-latest.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-GBDXSZFFSR"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-GBDXSZFFSR');
</script>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { 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;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">
<div class="book-summary">
<nav role="navigation">
<ul class="summary">
<li><a href="./">Hydroinformatics</a></li>
<li class="divider"></li>
<li class="chapter" data-level="1" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i><b>1</b> Introduction</a>
<ul>
<li class="chapter" data-level="1.0.1" data-path="index.html"><a href="index.html#to-help-me-keep-get-an-idea-of-who-is-using-this-resource-so-i-can-improve-it-in-the-future-please-consider-filling-out-any-or-all-of-this-survey-httpsforms.gle6zcntzvr1wzzuh6s7-thanks"><i class="fa fa-check"></i><b>1.0.1</b> To help me keep get an idea of who is using this resource so I can improve it in the future, please consider filling out any or all of this survey: https://forms.gle/6Zcntzvr1wZZUh6S7 Thanks!</a></li>
<li class="chapter" data-level="1.1" data-path="index.html"><a href="index.html#how-to-use-these-materials"><i class="fa fa-check"></i><b>1.1</b> How to use these materials</a></li>
<li class="chapter" data-level="1.2" data-path="index.html"><a href="index.html#table-of-contents"><i class="fa fa-check"></i><b>1.2</b> Table of contents:</a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="Plotting.html"><a href="Plotting.html"><i class="fa fa-check"></i><b>2</b> Intro to Plotting</a>
<ul>
<li class="chapter" data-level="2.1" data-path="Plotting.html"><a href="Plotting.html#download-and-install-tidyverse-library"><i class="fa fa-check"></i><b>2.1</b> Download and install tidyverse library</a></li>
<li class="chapter" data-level="2.2" data-path="Plotting.html"><a href="Plotting.html#reading-data"><i class="fa fa-check"></i><b>2.2</b> Reading data</a></li>
<li class="chapter" data-level="2.3" data-path="Plotting.html"><a href="Plotting.html#our-first-ggplot"><i class="fa fa-check"></i><b>2.3</b> Our first ggplot</a></li>
<li class="chapter" data-level="2.4" data-path="Plotting.html"><a href="Plotting.html#change-point-type"><i class="fa fa-check"></i><b>2.4</b> Change point type</a></li>
<li class="chapter" data-level="2.5" data-path="Plotting.html"><a href="Plotting.html#set-colors"><i class="fa fa-check"></i><b>2.5</b> Set colors</a></li>
<li class="chapter" data-level="2.6" data-path="Plotting.html"><a href="Plotting.html#controlling-color-with-a-third-variable-and-other-functions"><i class="fa fa-check"></i><b>2.6</b> Controlling color with a third variable and other functions</a></li>
<li class="chapter" data-level="2.7" data-path="Plotting.html"><a href="Plotting.html#plotting-multiple-groups"><i class="fa fa-check"></i><b>2.7</b> Plotting multiple groups</a></li>
<li class="chapter" data-level="2.8" data-path="Plotting.html"><a href="Plotting.html#facets"><i class="fa fa-check"></i><b>2.8</b> Facets</a></li>
<li class="chapter" data-level="2.9" data-path="Plotting.html"><a href="Plotting.html#two-variable-faceting"><i class="fa fa-check"></i><b>2.9</b> Two variable faceting</a></li>
<li class="chapter" data-level="2.10" data-path="Plotting.html"><a href="Plotting.html#boxplots"><i class="fa fa-check"></i><b>2.10</b> Boxplots</a></li>
<li class="chapter" data-level="2.11" data-path="Plotting.html"><a href="Plotting.html#more-about-color-size-etc"><i class="fa fa-check"></i><b>2.11</b> More about color, size, etc</a></li>
<li class="chapter" data-level="2.12" data-path="Plotting.html"><a href="Plotting.html#multiple-geoms"><i class="fa fa-check"></i><b>2.12</b> Multiple geoms</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="Programming.html"><a href="Programming.html"><i class="fa fa-check"></i><b>3</b> R Tidyverse Programming Basics</a>
<ul>
<li class="chapter" data-level="3.1" data-path="Programming.html"><a href="Programming.html#introduction-1"><i class="fa fa-check"></i><b>3.1</b> Introduction</a></li>
<li class="chapter" data-level="3.2" data-path="Programming.html"><a href="Programming.html#you-can-use-r-as-a-calculator"><i class="fa fa-check"></i><b>3.2</b> You can use R as a calculator</a></li>
<li class="chapter" data-level="3.3" data-path="Programming.html"><a href="Programming.html#you-can-create-new-objects-using--"><i class="fa fa-check"></i><b>3.3</b> You can create new objects using <-</a></li>
<li class="chapter" data-level="3.4" data-path="Programming.html"><a href="Programming.html#using-functions"><i class="fa fa-check"></i><b>3.4</b> Using functions</a></li>
<li class="chapter" data-level="3.5" data-path="Programming.html"><a href="Programming.html#read-in-some-data."><i class="fa fa-check"></i><b>3.5</b> Read in some data.</a></li>
<li class="chapter" data-level="3.6" data-path="Programming.html"><a href="Programming.html#wait-hold-up.-what-is-a-tibble"><i class="fa fa-check"></i><b>3.6</b> Wait, hold up. What is a tibble?</a></li>
<li class="chapter" data-level="3.7" data-path="Programming.html"><a href="Programming.html#data-wrangling-in-dplyr"><i class="fa fa-check"></i><b>3.7</b> Data wrangling in dplyr</a></li>
<li class="chapter" data-level="3.8" data-path="Programming.html"><a href="Programming.html#filter"><i class="fa fa-check"></i><b>3.8</b> Filter</a>
<ul>
<li class="chapter" data-level="3.8.1" data-path="Programming.html"><a href="Programming.html#multiple-conditions"><i class="fa fa-check"></i><b>3.8.1</b> Multiple conditions</a></li>
</ul></li>
<li class="chapter" data-level="3.9" data-path="Programming.html"><a href="Programming.html#arrange"><i class="fa fa-check"></i><b>3.9</b> Arrange</a></li>
<li class="chapter" data-level="3.10" data-path="Programming.html"><a href="Programming.html#select"><i class="fa fa-check"></i><b>3.10</b> Select</a></li>
<li class="chapter" data-level="3.11" data-path="Programming.html"><a href="Programming.html#mutate"><i class="fa fa-check"></i><b>3.11</b> Mutate</a></li>
<li class="chapter" data-level="3.12" data-path="Programming.html"><a href="Programming.html#summarize"><i class="fa fa-check"></i><b>3.12</b> Summarize</a></li>
<li class="chapter" data-level="3.13" data-path="Programming.html"><a href="Programming.html#multiple-operations-with-pipes"><i class="fa fa-check"></i><b>3.13</b> Multiple operations with pipes</a>
<ul>
<li class="chapter" data-level="3.13.1" data-path="Programming.html"><a href="Programming.html#lets-say-we-want-to-tell-r-to-make-a-pbj-sandwich-by-using-the-pbbread-jbread-and-joinslices-functions-and-the-data-ingredients.-if-we-do-this-saving-each-step-if-would-look-like-this"><i class="fa fa-check"></i><b>3.13.1</b> Let’s say we want to tell R to make a PB&J sandwich by using the pbbread(), jbread(), and joinslices() functions and the data “ingredients”. If we do this saving each step if would look like this:</a></li>
<li class="chapter" data-level="3.13.2" data-path="Programming.html"><a href="Programming.html#if-we-nest-the-functions-together-we-get-this"><i class="fa fa-check"></i><b>3.13.2</b> If we nest the functions together we get this</a></li>
<li class="chapter" data-level="3.13.3" data-path="Programming.html"><a href="Programming.html#using-the-pipe-it-would-look-like-this"><i class="fa fa-check"></i><b>3.13.3</b> Using the pipe it would look like this</a></li>
<li class="chapter" data-level="3.13.4" data-path="Programming.html"><a href="Programming.html#when-you-use-the-pipe-it-basically-takes-whatever-came-out-of-the-first-function-and-puts-it-into-the-data-argument-for-the-next-one"><i class="fa fa-check"></i><b>3.13.4</b> When you use the pipe, it basically takes whatever came out of the first function and puts it into the data argument for the next one</a></li>
</ul></li>
<li class="chapter" data-level="3.14" data-path="Programming.html"><a href="Programming.html#save-your-results-to-a-new-tibble"><i class="fa fa-check"></i><b>3.14</b> Save your results to a new tibble</a></li>
<li class="chapter" data-level="3.15" data-path="Programming.html"><a href="Programming.html#what-about-nas"><i class="fa fa-check"></i><b>3.15</b> What about NAs?</a></li>
<li class="chapter" data-level="3.16" data-path="Programming.html"><a href="Programming.html#what-are-some-things-you-think-ill-ask-you-to-do-for-the-activity-next-class"><i class="fa fa-check"></i><b>3.16</b> What are some things you think I’ll ask you to do for the activity next class?</a></li>
</ul></li>
<li class="chapter" data-level="4" data-path="introactivity.html"><a href="introactivity.html"><i class="fa fa-check"></i><b>4</b> ACTIVITY Intro Skills</a>
<ul>
<li class="chapter" data-level="4.1" data-path="introactivity.html"><a href="introactivity.html#problem-1"><i class="fa fa-check"></i><b>4.1</b> Problem 1</a></li>
<li class="chapter" data-level="4.2" data-path="introactivity.html"><a href="introactivity.html#problem-2"><i class="fa fa-check"></i><b>4.2</b> Problem 2</a></li>
<li class="chapter" data-level="4.3" data-path="introactivity.html"><a href="introactivity.html#problem-3"><i class="fa fa-check"></i><b>4.3</b> Problem 3</a></li>
<li class="chapter" data-level="4.4" data-path="introactivity.html"><a href="introactivity.html#problem-4"><i class="fa fa-check"></i><b>4.4</b> Problem 4</a></li>
<li class="chapter" data-level="4.5" data-path="introactivity.html"><a href="introactivity.html#problem-5"><i class="fa fa-check"></i><b>4.5</b> Problem 5</a></li>
<li class="chapter" data-level="4.6" data-path="introactivity.html"><a href="introactivity.html#problem-6"><i class="fa fa-check"></i><b>4.6</b> Problem 6</a></li>
</ul></li>
<li class="chapter" data-level="5" data-path="stats.html"><a href="stats.html"><i class="fa fa-check"></i><b>5</b> Introduction to Basic Statistics</a>
<ul>
<li class="chapter" data-level="5.1" data-path="stats.html"><a href="stats.html#reading-for-this-section-statistical-methods-in-water-resources-chapter-1"><i class="fa fa-check"></i><b>5.1</b> Reading for this section: Statistical Methods in Water Resources: Chapter 1</a></li>
<li class="chapter" data-level="5.2" data-path="stats.html"><a href="stats.html#questions-for-today"><i class="fa fa-check"></i><b>5.2</b> Questions for today:</a>
<ul>
<li class="chapter" data-level="5.2.1" data-path="stats.html"><a href="stats.html#stack-plots-to-compare-histogram-and-pdf"><i class="fa fa-check"></i><b>5.2.1</b> Stack plots to compare histogram and pdf</a></li>
</ul></li>
<li class="chapter" data-level="5.3" data-path="stats.html"><a href="stats.html#what-is-the-difference-between-a-sample-and-a-population."><i class="fa fa-check"></i><b>5.3</b> What is the difference between a sample and a population.</a></li>
<li class="chapter" data-level="5.4" data-path="stats.html"><a href="stats.html#measuring-our-sample-distribution-central-tendency."><i class="fa fa-check"></i><b>5.4</b> Measuring our sample distribution: central tendency.</a>
<ul>
<li class="chapter" data-level="5.4.1" data-path="stats.html"><a href="stats.html#so-whats-a-weighted-average"><i class="fa fa-check"></i><b>5.4.1</b> So what’s a weighted average?</a></li>
</ul></li>
<li class="chapter" data-level="5.5" data-path="stats.html"><a href="stats.html#measures-of-variability"><i class="fa fa-check"></i><b>5.5</b> Measures of variability</a></li>
<li class="chapter" data-level="5.6" data-path="stats.html"><a href="stats.html#what-is-a-normal-distribution-and-how-can-we-determine-if-we-have-one"><i class="fa fa-check"></i><b>5.6</b> What is a normal distribution and how can we determine if we have one?</a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="statsactivity.html"><a href="statsactivity.html"><i class="fa fa-check"></i><b>6</b> ACTIVITY Intro Stats</a>
<ul>
<li class="chapter" data-level="6.1" data-path="statsactivity.html"><a href="statsactivity.html#problem-1-1"><i class="fa fa-check"></i><b>6.1</b> Problem 1</a></li>
<li class="chapter" data-level="6.2" data-path="statsactivity.html"><a href="statsactivity.html#problem-2-1"><i class="fa fa-check"></i><b>6.2</b> Problem 2</a></li>
<li class="chapter" data-level="6.3" data-path="statsactivity.html"><a href="statsactivity.html#problem-3-1"><i class="fa fa-check"></i><b>6.3</b> Problem 3</a></li>
<li class="chapter" data-level="6.4" data-path="statsactivity.html"><a href="statsactivity.html#problem-4-1"><i class="fa fa-check"></i><b>6.4</b> Problem 4</a></li>
<li class="chapter" data-level="6.5" data-path="statsactivity.html"><a href="statsactivity.html#problem-5-1"><i class="fa fa-check"></i><b>6.5</b> Problem 5</a></li>
<li class="chapter" data-level="6.6" data-path="statsactivity.html"><a href="statsactivity.html#problem-6-1"><i class="fa fa-check"></i><b>6.6</b> Problem 6</a></li>
</ul></li>
<li class="chapter" data-level="7" data-path="getdata.html"><a href="getdata.html"><i class="fa fa-check"></i><b>7</b> Joins, Pivots, and USGS dataRetrieval</a>
<ul>
<li class="chapter" data-level="7.1" data-path="getdata.html"><a href="getdata.html#goals-for-today"><i class="fa fa-check"></i><b>7.1</b> Goals for today</a></li>
<li class="chapter" data-level="7.2" data-path="getdata.html"><a href="getdata.html#exploring-what-dataretrieval-can-do."><i class="fa fa-check"></i><b>7.2</b> Exploring what dataRetrieval can do.</a></li>
<li class="chapter" data-level="7.3" data-path="getdata.html"><a href="getdata.html#joins"><i class="fa fa-check"></i><b>7.3</b> Joins</a></li>
<li class="chapter" data-level="7.4" data-path="getdata.html"><a href="getdata.html#join-example"><i class="fa fa-check"></i><b>7.4</b> Join example</a></li>
<li class="chapter" data-level="7.5" data-path="getdata.html"><a href="getdata.html#finding-ids-to-download-usgs-data"><i class="fa fa-check"></i><b>7.5</b> Finding IDs to download USGS data</a></li>
<li class="chapter" data-level="7.6" data-path="getdata.html"><a href="getdata.html#ok-lets-download-some-data"><i class="fa fa-check"></i><b>7.6</b> OK let’s download some data!</a></li>
<li class="chapter" data-level="7.7" data-path="getdata.html"><a href="getdata.html#pivoting-wide-and-long-data"><i class="fa fa-check"></i><b>7.7</b> Pivoting: wide and long data</a></li>
<li class="chapter" data-level="7.8" data-path="getdata.html"><a href="getdata.html#pivot-examples"><i class="fa fa-check"></i><b>7.8</b> Pivot Examples</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="joinpivotDR.html"><a href="joinpivotDR.html"><i class="fa fa-check"></i><b>8</b> ACTIVITY: Joins Pivots dataRetrieval</a>
<ul>
<li class="chapter" data-level="8.1" data-path="joinpivotDR.html"><a href="joinpivotDR.html#load-the-tidyverse-dataretrieval-and-patchwork-packages."><i class="fa fa-check"></i><b>8.1</b> Load the tidyverse, dataRetrieval, and patchwork packages.</a></li>
<li class="chapter" data-level="8.2" data-path="joinpivotDR.html"><a href="joinpivotDR.html#problem-1-2"><i class="fa fa-check"></i><b>8.2</b> Problem 1</a></li>
<li class="chapter" data-level="8.3" data-path="joinpivotDR.html"><a href="joinpivotDR.html#problem-2-2"><i class="fa fa-check"></i><b>8.3</b> Problem 2</a></li>
<li class="chapter" data-level="8.4" data-path="joinpivotDR.html"><a href="joinpivotDR.html#problem-3-2"><i class="fa fa-check"></i><b>8.4</b> Problem 3</a></li>
<li class="chapter" data-level="8.5" data-path="joinpivotDR.html"><a href="joinpivotDR.html#problem-4-2"><i class="fa fa-check"></i><b>8.5</b> Problem 4</a></li>
<li class="chapter" data-level="8.6" data-path="joinpivotDR.html"><a href="joinpivotDR.html#problem-5-2"><i class="fa fa-check"></i><b>8.6</b> Problem 5</a></li>
<li class="chapter" data-level="8.7" data-path="joinpivotDR.html"><a href="joinpivotDR.html#problem-6-2"><i class="fa fa-check"></i><b>8.7</b> Problem 6</a></li>
<li class="chapter" data-level="8.8" data-path="joinpivotDR.html"><a href="joinpivotDR.html#problem-7"><i class="fa fa-check"></i><b>8.8</b> Problem 7</a></li>
</ul></li>
<li class="chapter" data-level="9" data-path="Summative1.html"><a href="Summative1.html"><i class="fa fa-check"></i><b>9</b> ACTIVITY Summative 1</a>
<ul>
<li class="chapter" data-level="9.0.1" data-path="Summative1.html"><a href="Summative1.html#instructions"><i class="fa fa-check"></i><b>9.0.1</b> Instructions</a></li>
<li class="chapter" data-level="9.1" data-path="Summative1.html"><a href="Summative1.html#problem-1-3"><i class="fa fa-check"></i><b>9.1</b> Problem 1</a></li>
<li class="chapter" data-level="9.2" data-path="Summative1.html"><a href="Summative1.html#problem-2-3"><i class="fa fa-check"></i><b>9.2</b> Problem 2</a></li>
<li class="chapter" data-level="9.3" data-path="Summative1.html"><a href="Summative1.html#problem-3-3"><i class="fa fa-check"></i><b>9.3</b> Problem 3</a></li>
<li class="chapter" data-level="9.4" data-path="Summative1.html"><a href="Summative1.html#problem-4-3"><i class="fa fa-check"></i><b>9.4</b> Problem 4</a></li>
<li class="chapter" data-level="9.5" data-path="Summative1.html"><a href="Summative1.html#problem-5-3"><i class="fa fa-check"></i><b>9.5</b> Problem 5</a></li>
<li class="chapter" data-level="9.6" data-path="Summative1.html"><a href="Summative1.html#problem-6-3"><i class="fa fa-check"></i><b>9.6</b> Problem 6</a></li>
<li class="chapter" data-level="9.7" data-path="Summative1.html"><a href="Summative1.html#problem-7-1"><i class="fa fa-check"></i><b>9.7</b> Problem 7</a></li>
<li class="chapter" data-level="9.8" data-path="Summative1.html"><a href="Summative1.html#problem-8"><i class="fa fa-check"></i><b>9.8</b> Problem 8</a></li>
<li class="chapter" data-level="9.9" data-path="Summative1.html"><a href="Summative1.html#problem-9"><i class="fa fa-check"></i><b>9.9</b> Problem 9</a></li>
<li class="chapter" data-level="9.10" data-path="Summative1.html"><a href="Summative1.html#problem-10"><i class="fa fa-check"></i><b>9.10</b> Problem 10</a></li>
</ul></li>
<li class="chapter" data-level="10" data-path="fdcs.html"><a href="fdcs.html"><i class="fa fa-check"></i><b>10</b> Flow Duration Curves</a>
<ul>
<li class="chapter" data-level="10.1" data-path="fdcs.html"><a href="fdcs.html#get-data"><i class="fa fa-check"></i><b>10.1</b> Get data</a></li>
<li class="chapter" data-level="10.2" data-path="fdcs.html"><a href="fdcs.html#review-describe-the-distribution"><i class="fa fa-check"></i><b>10.2</b> Review: describe the distribution</a></li>
<li class="chapter" data-level="10.3" data-path="fdcs.html"><a href="fdcs.html#ecdfs"><i class="fa fa-check"></i><b>10.3</b> ECDFs</a></li>
<li class="chapter" data-level="10.4" data-path="fdcs.html"><a href="fdcs.html#calculate-flow-exceedence-probabilities"><i class="fa fa-check"></i><b>10.4</b> Calculate flow exceedence probabilities</a></li>
<li class="chapter" data-level="10.5" data-path="fdcs.html"><a href="fdcs.html#plot-a-flow-duration-curve-using-the-probabilities"><i class="fa fa-check"></i><b>10.5</b> Plot a Flow Duration Curve using the probabilities</a></li>
<li class="chapter" data-level="10.6" data-path="fdcs.html"><a href="fdcs.html#make-an-almost-fdc-with-stat_ecdf"><i class="fa fa-check"></i><b>10.6</b> Make an almost FDC with stat_ecdf</a></li>
<li class="chapter" data-level="10.7" data-path="fdcs.html"><a href="fdcs.html#example-use-of-an-fdc"><i class="fa fa-check"></i><b>10.7</b> Example use of an FDC</a></li>
<li class="chapter" data-level="10.8" data-path="fdcs.html"><a href="fdcs.html#compare-to-a-boxplot-of-the-same-data"><i class="fa fa-check"></i><b>10.8</b> Compare to a boxplot of the same data</a></li>
<li class="chapter" data-level="10.9" data-path="fdcs.html"><a href="fdcs.html#challenge-examining-flow-regime-change-at-the-grand-canyon"><i class="fa fa-check"></i><b>10.9</b> Challenge: Examining flow regime change at the Grand Canyon</a></li>
</ul></li>
<li class="chapter" data-level="11" data-path="lfas.html"><a href="lfas.html"><i class="fa fa-check"></i><b>11</b> Low Flow Analysis</a>
<ul>
<li class="chapter" data-level="11.1" data-path="lfas.html"><a href="lfas.html#what-are-low-flow-statistics"><i class="fa fa-check"></i><b>11.1</b> What are low flow statistics?</a></li>
<li class="chapter" data-level="11.2" data-path="lfas.html"><a href="lfas.html#get-data-1"><i class="fa fa-check"></i><b>11.2</b> Get data</a></li>
<li class="chapter" data-level="11.3" data-path="lfas.html"><a href="lfas.html#create-the-x-days-average-flow-record"><i class="fa fa-check"></i><b>11.3</b> Create the X days average flow record</a></li>
<li class="chapter" data-level="11.4" data-path="lfas.html"><a href="lfas.html#look-at-what-a-rolling-mean-does."><i class="fa fa-check"></i><b>11.4</b> Look at what a rolling mean does.</a></li>
<li class="chapter" data-level="11.5" data-path="lfas.html"><a href="lfas.html#calculate-yearly-minimums"><i class="fa fa-check"></i><b>11.5</b> Calculate yearly minimums</a></li>
<li class="chapter" data-level="11.6" data-path="lfas.html"><a href="lfas.html#calculate-return-interval"><i class="fa fa-check"></i><b>11.6</b> Calculate return interval</a></li>
<li class="chapter" data-level="11.7" data-path="lfas.html"><a href="lfas.html#fit-to-pearson-type-iii-distribution"><i class="fa fa-check"></i><b>11.7</b> Fit to Pearson Type III distribution</a></li>
<li class="chapter" data-level="11.8" data-path="lfas.html"><a href="lfas.html#distribution-free-method"><i class="fa fa-check"></i><b>11.8</b> Distribution-free method</a></li>
</ul></li>
<li class="chapter" data-level="12" data-path="floods.html"><a href="floods.html"><i class="fa fa-check"></i><b>12</b> Flood Frequency Analysis and Creating Functions</a>
<ul>
<li class="chapter" data-level="12.1" data-path="floods.html"><a href="floods.html#template-repository"><i class="fa fa-check"></i><b>12.1</b> Template Repository</a></li>
<li class="chapter" data-level="12.2" data-path="floods.html"><a href="floods.html#intro"><i class="fa fa-check"></i><b>12.2</b> Intro</a></li>
<li class="chapter" data-level="12.3" data-path="floods.html"><a href="floods.html#challenge-create-a-function"><i class="fa fa-check"></i><b>12.3</b> Challenge: Create a function</a></li>
</ul></li>
<li class="chapter" data-level="13" data-path="rgeospatial.html"><a href="rgeospatial.html"><i class="fa fa-check"></i><b>13</b> Geospatial data in R - Vector</a>
<ul>
<li class="chapter" data-level="13.1" data-path="rgeospatial.html"><a href="rgeospatial.html#goals"><i class="fa fa-check"></i><b>13.1</b> Goals</a></li>
<li class="chapter" data-level="13.2" data-path="rgeospatial.html"><a href="rgeospatial.html#intro-to-tmap"><i class="fa fa-check"></i><b>13.2</b> Intro to tmap</a></li>
<li class="chapter" data-level="13.3" data-path="rgeospatial.html"><a href="rgeospatial.html#data-wrangling-with-tidyverse-principles"><i class="fa fa-check"></i><b>13.3</b> Data wrangling with tidyverse principles</a></li>
<li class="chapter" data-level="13.4" data-path="rgeospatial.html"><a href="rgeospatial.html#plot-maps-side-by-side"><i class="fa fa-check"></i><b>13.4</b> Plot maps side by side</a></li>
<li class="chapter" data-level="13.5" data-path="rgeospatial.html"><a href="rgeospatial.html#built-in-styles-like-themes-in-ggplot"><i class="fa fa-check"></i><b>13.5</b> Built in styles, like themes in ggplot</a></li>
<li class="chapter" data-level="13.6" data-path="rgeospatial.html"><a href="rgeospatial.html#interactive-maps"><i class="fa fa-check"></i><b>13.6</b> Interactive Maps</a>
<ul>
<li class="chapter" data-level="13.6.1" data-path="rgeospatial.html"><a href="rgeospatial.html#tmap"><i class="fa fa-check"></i><b>13.6.1</b> tmap</a></li>
<li class="chapter" data-level="13.6.2" data-path="rgeospatial.html"><a href="rgeospatial.html#leaflet"><i class="fa fa-check"></i><b>13.6.2</b> Leaflet</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="14" data-path="summative2.html"><a href="summative2.html"><i class="fa fa-check"></i><b>14</b> Summative Assessment 2</a>
<ul>
<li class="chapter" data-level="14.1" data-path="summative2.html"><a href="summative2.html#info-for-assessment"><i class="fa fa-check"></i><b>14.1</b> Info for assessment</a></li>
</ul></li>
<li class="chapter" data-level="15" data-path="rgeoraster.html"><a href="rgeoraster.html"><i class="fa fa-check"></i><b>15</b> Geospatial R Raster - Hydro Analyses</a>
<ul>
<li class="chapter" data-level="15.1" data-path="rgeoraster.html"><a href="rgeoraster.html#introduction-2"><i class="fa fa-check"></i><b>15.1</b> Introduction</a></li>
<li class="chapter" data-level="15.2" data-path="rgeoraster.html"><a href="rgeoraster.html#read-in-dem"><i class="fa fa-check"></i><b>15.2</b> Read in DEM</a></li>
<li class="chapter" data-level="15.3" data-path="rgeoraster.html"><a href="rgeoraster.html#plot-dem"><i class="fa fa-check"></i><b>15.3</b> Plot DEM</a></li>
<li class="chapter" data-level="15.4" data-path="rgeoraster.html"><a href="rgeoraster.html#generate-a-hillshade"><i class="fa fa-check"></i><b>15.4</b> Generate a hillshade</a>
<ul>
<li class="chapter" data-level="15.4.1" data-path="rgeoraster.html"><a href="rgeoraster.html#how-whitebox-tools-functions-work"><i class="fa fa-check"></i><b>15.4.1</b> How whitebox tools functions work</a></li>
</ul></li>
<li class="chapter" data-level="15.5" data-path="rgeoraster.html"><a href="rgeoraster.html#prepare-dem-for-hydrology-analyses"><i class="fa fa-check"></i><b>15.5</b> Prepare DEM for Hydrology Analyses</a></li>
<li class="chapter" data-level="15.6" data-path="rgeoraster.html"><a href="rgeoraster.html#visualize-filled-sinks-and-breached-depressions"><i class="fa fa-check"></i><b>15.6</b> Visualize filled sinks and breached depressions</a></li>
<li class="chapter" data-level="15.7" data-path="rgeoraster.html"><a href="rgeoraster.html#d8-flow-accumulation"><i class="fa fa-check"></i><b>15.7</b> D8 Flow Accumulation</a></li>
<li class="chapter" data-level="15.8" data-path="rgeoraster.html"><a href="rgeoraster.html#d-infinity-flow-accumulation"><i class="fa fa-check"></i><b>15.8</b> D infinity flow accumulation</a></li>
<li class="chapter" data-level="15.9" data-path="rgeoraster.html"><a href="rgeoraster.html#topographic-wetness-index"><i class="fa fa-check"></i><b>15.9</b> Topographic Wetness Index</a></li>
<li class="chapter" data-level="15.10" data-path="rgeoraster.html"><a href="rgeoraster.html#downslope-twi"><i class="fa fa-check"></i><b>15.10</b> Downslope TWI</a></li>
<li class="chapter" data-level="15.11" data-path="rgeoraster.html"><a href="rgeoraster.html#map-stream-network"><i class="fa fa-check"></i><b>15.11</b> Map Stream Network</a></li>
<li class="chapter" data-level="15.12" data-path="rgeoraster.html"><a href="rgeoraster.html#extract-raster-values-to-point-locations"><i class="fa fa-check"></i><b>15.12</b> Extract raster values to point locations</a>
<ul>
<li class="chapter" data-level="15.12.1" data-path="rgeoraster.html"><a href="rgeoraster.html#import-and-plot-points"><i class="fa fa-check"></i><b>15.12.1</b> Import and plot points</a></li>
<li class="chapter" data-level="15.12.2" data-path="rgeoraster.html"><a href="rgeoraster.html#extract-values-from-multiple-rasters-at-once"><i class="fa fa-check"></i><b>15.12.2</b> Extract values from multiple rasters at once</a></li>
</ul></li>
<li class="chapter" data-level="15.13" data-path="rgeoraster.html"><a href="rgeoraster.html#view-raster-data-as-a-pdf-or-histogram"><i class="fa fa-check"></i><b>15.13</b> View raster data as a PDF or histogram</a></li>
<li class="chapter" data-level="15.14" data-path="rgeoraster.html"><a href="rgeoraster.html#subsetting-a-raster-for-visualization"><i class="fa fa-check"></i><b>15.14</b> Subsetting a raster for visualization</a></li>
<li class="chapter" data-level="15.15" data-path="rgeoraster.html"><a href="rgeoraster.html#raster-math"><i class="fa fa-check"></i><b>15.15</b> Raster Math</a></li>
<li class="chapter" data-level="15.16" data-path="rgeoraster.html"><a href="rgeoraster.html#extra-plot-topo-characteristics-against-one-another"><i class="fa fa-check"></i><b>15.16</b> Extra: plot topo characteristics against one another</a></li>
</ul></li>
<li class="chapter" data-level="16" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html"><i class="fa fa-check"></i><b>16</b> Geospatial R Raster - Watershed Delineation</a>
<ul>
<li class="chapter" data-level="16.1" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#introduction-3"><i class="fa fa-check"></i><b>16.1</b> Introduction</a></li>
<li class="chapter" data-level="16.2" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#the-watershed-delineation-toolprocess"><i class="fa fa-check"></i><b>16.2</b> The watershed delineation tool/process</a></li>
<li class="chapter" data-level="16.3" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#read-in-dem-1"><i class="fa fa-check"></i><b>16.3</b> Read in DEM</a></li>
<li class="chapter" data-level="16.4" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#generate-a-hillshade-1"><i class="fa fa-check"></i><b>16.4</b> Generate a hillshade</a></li>
<li class="chapter" data-level="16.5" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#prepare-dem-for-hydrology-analyses-1"><i class="fa fa-check"></i><b>16.5</b> Prepare DEM for Hydrology Analyses</a></li>
<li class="chapter" data-level="16.6" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#create-flow-accumulation-and-pointer-grids"><i class="fa fa-check"></i><b>16.6</b> Create flow accumulation and pointer grids</a></li>
<li class="chapter" data-level="16.7" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#setting-pour-points"><i class="fa fa-check"></i><b>16.7</b> Setting pour points</a></li>
<li class="chapter" data-level="16.8" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#delineate-watersheds"><i class="fa fa-check"></i><b>16.8</b> Delineate watersheds</a></li>
<li class="chapter" data-level="16.9" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#convert-watersheds-to-shapefiles"><i class="fa fa-check"></i><b>16.9</b> Convert watersheds to shapefiles</a></li>
<li class="chapter" data-level="16.10" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#extract-data-based-on-watershed-outline"><i class="fa fa-check"></i><b>16.10</b> Extract data based on watershed outline</a></li>
<li class="chapter" data-level="16.11" data-path="rgeowatersheds.html"><a href="rgeowatersheds.html#bonus-make-a-3d-map-of-your-watershed-with-rayshader"><i class="fa fa-check"></i><b>16.11</b> BONUS: Make a 3d map of your watershed with rayshader</a></li>
</ul></li>
<li class="chapter" data-level="17" data-path="modelingintro.html"><a href="modelingintro.html"><i class="fa fa-check"></i><b>17</b> Intro to Modeling - Getting Started with HBV</a>
<ul>
<li class="chapter" data-level="17.1" data-path="modelingintro.html"><a href="modelingintro.html#introduction-4"><i class="fa fa-check"></i><b>17.1</b> Introduction</a></li>
<li class="chapter" data-level="17.2" data-path="modelingintro.html"><a href="modelingintro.html#creating-the-hbv-model-function"><i class="fa fa-check"></i><b>17.2</b> Creating the HBV model function</a></li>
<li class="chapter" data-level="17.3" data-path="modelingintro.html"><a href="modelingintro.html#read-in-precip-and-temp"><i class="fa fa-check"></i><b>17.3</b> Read in Precip and Temp</a></li>
<li class="chapter" data-level="17.4" data-path="modelingintro.html"><a href="modelingintro.html#calculate-pet"><i class="fa fa-check"></i><b>17.4</b> Calculate PET</a></li>
<li class="chapter" data-level="17.5" data-path="modelingintro.html"><a href="modelingintro.html#hbv-parameters"><i class="fa fa-check"></i><b>17.5</b> HBV Parameters</a></li>
<li class="chapter" data-level="17.6" data-path="modelingintro.html"><a href="modelingintro.html#first-model-run"><i class="fa fa-check"></i><b>17.6</b> First model run</a></li>
<li class="chapter" data-level="17.7" data-path="modelingintro.html"><a href="modelingintro.html#import-observed-streamflow-data"><i class="fa fa-check"></i><b>17.7</b> Import observed streamflow data</a></li>
<li class="chapter" data-level="17.8" data-path="modelingintro.html"><a href="modelingintro.html#compare-observed-and-modeled-discharge-graphically"><i class="fa fa-check"></i><b>17.8</b> Compare observed and modeled discharge graphically</a></li>
<li class="chapter" data-level="17.9" data-path="modelingintro.html"><a href="modelingintro.html#compare-observed-and-modelled-discharge-with-interactive-graph"><i class="fa fa-check"></i><b>17.9</b> Compare observed and modelled discharge with interactive graph</a></li>
<li class="chapter" data-level="17.10" data-path="modelingintro.html"><a href="modelingintro.html#measure-how-well-the-model-fits-with-nse"><i class="fa fa-check"></i><b>17.10</b> Measure how well the model fits with NSE</a></li>
<li class="chapter" data-level="17.11" data-path="modelingintro.html"><a href="modelingintro.html#assess-model-fit-with-a-different-measure-snow"><i class="fa fa-check"></i><b>17.11</b> Assess model fit with a different measure: Snow</a></li>
<li class="chapter" data-level="17.12" data-path="modelingintro.html"><a href="modelingintro.html#calibrate-hbv-manually"><i class="fa fa-check"></i><b>17.12</b> Calibrate HBV manually</a></li>
</ul></li>
<li class="chapter" data-level="18" data-path="modelingcalibration.html"><a href="modelingcalibration.html"><i class="fa fa-check"></i><b>18</b> Intro to Modeling - Calibrate HBV</a>
<ul>
<li class="chapter" data-level="18.1" data-path="modelingcalibration.html"><a href="modelingcalibration.html#introduction-5"><i class="fa fa-check"></i><b>18.1</b> Introduction</a></li>
<li class="chapter" data-level="18.2" data-path="modelingcalibration.html"><a href="modelingcalibration.html#challenge-write-a-for-loop"><i class="fa fa-check"></i><b>18.2</b> Challenge: Write a for loop</a></li>
<li class="chapter" data-level="18.3" data-path="modelingcalibration.html"><a href="modelingcalibration.html#prep-data-for-hbv"><i class="fa fa-check"></i><b>18.3</b> Prep data for HBV</a></li>
<li class="chapter" data-level="18.4" data-path="modelingcalibration.html"><a href="modelingcalibration.html#calculate-pet-1"><i class="fa fa-check"></i><b>18.4</b> Calculate PET</a></li>
<li class="chapter" data-level="18.5" data-path="modelingcalibration.html"><a href="modelingcalibration.html#monte-carlo-step-1-generate-random-parameter-sets"><i class="fa fa-check"></i><b>18.5</b> Monte Carlo step 1: generate random parameter sets</a></li>
<li class="chapter" data-level="18.6" data-path="modelingcalibration.html"><a href="modelingcalibration.html#run-the-model-for-each-parameter-set"><i class="fa fa-check"></i><b>18.6</b> Run the model for each parameter set</a></li>
<li class="chapter" data-level="18.7" data-path="modelingcalibration.html"><a href="modelingcalibration.html#find-the-best-parameter-set"><i class="fa fa-check"></i><b>18.7</b> Find the best parameter set</a></li>
<li class="chapter" data-level="18.8" data-path="modelingcalibration.html"><a href="modelingcalibration.html#investigating-a-much-bigger-monte-carlo"><i class="fa fa-check"></i><b>18.8</b> Investigating a much bigger Monte Carlo</a></li>
</ul></li>
<li class="divider"></li>
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Hydroinformatics at VT</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal" id="section-">
<div id="stats" class="section level1 hasAnchor" number="5">
<h1><span class="header-section-number">Chapter 5</span> Introduction to Basic Statistics<a href="stats.html#stats" class="anchor-section" aria-label="Anchor link to header"></a></h1>
<p>Get this document and a version with empty code chunks at the template repository on github: <a href="https://github.com/VT-Hydroinformatics/4-Intro-Stats" class="uri">https://github.com/VT-Hydroinformatics/4-Intro-Stats</a></p>
<div class="sourceCode" id="cb76"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb76-1"><a href="stats.html#cb76-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyverse)</span>
<span id="cb76-2"><a href="stats.html#cb76-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(patchwork)</span>
<span id="cb76-3"><a href="stats.html#cb76-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb76-4"><a href="stats.html#cb76-4" aria-hidden="true" tabindex="-1"></a><span class="fu">theme_set</span>(<span class="fu">theme_classic</span>())</span></code></pre></div>
<div id="reading-for-this-section-statistical-methods-in-water-resources-chapter-1" class="section level2 hasAnchor" number="5.1">
<h2><span class="header-section-number">5.1</span> Reading for this section: Statistical Methods in Water Resources: Chapter 1<a href="stats.html#reading-for-this-section-statistical-methods-in-water-resources-chapter-1" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p><a href="https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf" class="uri">https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf</a></p>
</div>
<div id="questions-for-today" class="section level2 hasAnchor" number="5.2">
<h2><span class="header-section-number">5.2</span> Questions for today:<a href="stats.html#questions-for-today" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<ul>
<li><em>What is the difference between a sample and a population?</em></li>
<li><em>How do we look at the distribution of data in a sample</em></li>
<li><em>How do we measure aspects of a distribution</em></li>
<li><em>What is a normal distribution?</em></li>
</ul>
<p>First let’s generate some synthetic data and talk about how to visualize it.</p>
<div class="sourceCode" id="cb77"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb77-1"><a href="stats.html#cb77-1" aria-hidden="true" tabindex="-1"></a><span class="co">#generate a normal distribution</span></span>
<span id="cb77-2"><a href="stats.html#cb77-2" aria-hidden="true" tabindex="-1"></a>ExNorm <span class="ot"><-</span> <span class="fu">rnorm</span>(<span class="dv">1000</span>, <span class="at">mean =</span> <span class="dv">5</span>) <span class="sc">%>%</span> </span>
<span id="cb77-3"><a href="stats.html#cb77-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">as_tibble</span>()</span>
<span id="cb77-4"><a href="stats.html#cb77-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb77-5"><a href="stats.html#cb77-5" aria-hidden="true" tabindex="-1"></a><span class="co">#look at distributions</span></span>
<span id="cb77-6"><a href="stats.html#cb77-6" aria-hidden="true" tabindex="-1"></a><span class="co">#histogram</span></span>
<span id="cb77-7"><a href="stats.html#cb77-7" aria-hidden="true" tabindex="-1"></a>ExNorm <span class="sc">%>%</span></span>
<span id="cb77-8"><a href="stats.html#cb77-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value)) <span class="sc">+</span></span>
<span id="cb77-9"><a href="stats.html#cb77-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>()</span></code></pre></div>
<pre><code>## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
<p><img src="Hydroinformatics_Bookdown_files/figure-html/unnamed-chunk-42-1.png" width="672" /></p>
<div class="sourceCode" id="cb79"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb79-1"><a href="stats.html#cb79-1" aria-hidden="true" tabindex="-1"></a><span class="co">#pdf</span></span>
<span id="cb79-2"><a href="stats.html#cb79-2" aria-hidden="true" tabindex="-1"></a>ExNorm <span class="sc">%>%</span></span>
<span id="cb79-3"><a href="stats.html#cb79-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value)) <span class="sc">+</span></span>
<span id="cb79-4"><a href="stats.html#cb79-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_density</span>()</span></code></pre></div>
<p><img src="Hydroinformatics_Bookdown_files/figure-html/unnamed-chunk-42-2.png" width="672" /></p>
<div class="sourceCode" id="cb80"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb80-1"><a href="stats.html#cb80-1" aria-hidden="true" tabindex="-1"></a><span class="co">#Let's generate a plot that makes comparing these two easier</span></span></code></pre></div>
<div id="stack-plots-to-compare-histogram-and-pdf" class="section level3 hasAnchor" number="5.2.1">
<h3><span class="header-section-number">5.2.1</span> Stack plots to compare histogram and pdf<a href="stats.html#stack-plots-to-compare-histogram-and-pdf" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>We will save each plot as ggplot object and then output them using the patchwork package (loaded in the setup chunk).</p>
<p>What is the difference between a histogram and a pdf?<br />
What features of the histogram are preserved? Which are lost?</p>
<div class="sourceCode" id="cb81"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb81-1"><a href="stats.html#cb81-1" aria-hidden="true" tabindex="-1"></a><span class="co">#histogram</span></span>
<span id="cb81-2"><a href="stats.html#cb81-2" aria-hidden="true" tabindex="-1"></a>exhist <span class="ot"><-</span> ExNorm <span class="sc">%>%</span></span>
<span id="cb81-3"><a href="stats.html#cb81-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value)) <span class="sc">+</span></span>
<span id="cb81-4"><a href="stats.html#cb81-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>()</span>
<span id="cb81-5"><a href="stats.html#cb81-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb81-6"><a href="stats.html#cb81-6" aria-hidden="true" tabindex="-1"></a><span class="co">#pdf</span></span>
<span id="cb81-7"><a href="stats.html#cb81-7" aria-hidden="true" tabindex="-1"></a>expdf <span class="ot"><-</span> ExNorm <span class="sc">%>%</span></span>
<span id="cb81-8"><a href="stats.html#cb81-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value)) <span class="sc">+</span></span>
<span id="cb81-9"><a href="stats.html#cb81-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_density</span>()</span>
<span id="cb81-10"><a href="stats.html#cb81-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb81-11"><a href="stats.html#cb81-11" aria-hidden="true" tabindex="-1"></a><span class="co">#put the plots side by side with + or on top of each other with /</span></span>
<span id="cb81-12"><a href="stats.html#cb81-12" aria-hidden="true" tabindex="-1"></a>exhist<span class="sc">/</span>expdf</span></code></pre></div>
<pre><code>## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
<p><img src="Hydroinformatics_Bookdown_files/figure-html/unnamed-chunk-43-1.png" width="672" /></p>
</div>
</div>
<div id="what-is-the-difference-between-a-sample-and-a-population." class="section level2 hasAnchor" number="5.3">
<h2><span class="header-section-number">5.3</span> What is the difference between a sample and a population.<a href="stats.html#what-is-the-difference-between-a-sample-and-a-population." class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>Simply put: a population is the thing you are trying to measure. A sample is the data you measure in an effort to measure the population. A sample is a subset of a population.</p>
<p>Let’s write some code for an example:</p>
<p>We will create a POPULATION that is a large set of numbers. Think of this is as the concentration of Calcium in every bit of water in a lake. Then we will create a SAMPLE by randomly grabbing values from the POPULATION. This simulates us going around in a boat and taking grab samples in an effort to figure out the concentration of calcium in the lake.</p>
<p>We can then run this code a bunch of times, you’ll get a different sample each time. You can also take a smaller or larger number of samples by changing “size” in the sample() function.</p>
<p>How does your sample distribution look similar or different from the population?<br />
Why does the sample change every time you run it?<br />
What happens as you increase or decrease the number of samples?<br />
What happens if you set the number of samples to the size of the population?</p>
<div class="sourceCode" id="cb83"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb83-1"><a href="stats.html#cb83-1" aria-hidden="true" tabindex="-1"></a>all_the_water <span class="ot"><-</span> <span class="fu">rnorm</span>(<span class="dv">10000</span>, <span class="at">mean =</span> <span class="dv">6</span>) <span class="sc">%>%</span> <span class="fu">as_tibble</span>()</span>
<span id="cb83-2"><a href="stats.html#cb83-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-3"><a href="stats.html#cb83-3" aria-hidden="true" tabindex="-1"></a>sample_of_water <span class="ot"><-</span> <span class="fu">sample</span>(all_the_water<span class="sc">$</span>value, <span class="at">size =</span> <span class="dv">100</span>, <span class="at">replace =</span> <span class="cn">FALSE</span>) <span class="sc">%>%</span> <span class="fu">as_tibble</span>()</span>
<span id="cb83-4"><a href="stats.html#cb83-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-5"><a href="stats.html#cb83-5" aria-hidden="true" tabindex="-1"></a>population_hist <span class="ot"><-</span> all_the_water <span class="sc">%>%</span></span>
<span id="cb83-6"><a href="stats.html#cb83-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value))<span class="sc">+</span></span>
<span id="cb83-7"><a href="stats.html#cb83-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>()<span class="sc">+</span></span>
<span id="cb83-8"><a href="stats.html#cb83-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Population: All the water in the lake"</span>)</span>
<span id="cb83-9"><a href="stats.html#cb83-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-10"><a href="stats.html#cb83-10" aria-hidden="true" tabindex="-1"></a>sample_hist <span class="ot"><-</span> sample_of_water <span class="sc">%>%</span></span>
<span id="cb83-11"><a href="stats.html#cb83-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value))<span class="sc">+</span></span>
<span id="cb83-12"><a href="stats.html#cb83-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>()<span class="sc">+</span></span>
<span id="cb83-13"><a href="stats.html#cb83-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Your sample of the lake"</span>)</span>
<span id="cb83-14"><a href="stats.html#cb83-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb83-15"><a href="stats.html#cb83-15" aria-hidden="true" tabindex="-1"></a>population_hist <span class="sc">+</span> sample_hist</span></code></pre></div>
<pre><code>## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
<p><img src="Hydroinformatics_Bookdown_files/figure-html/unnamed-chunk-44-1.png" width="672" /></p>
</div>
<div id="measuring-our-sample-distribution-central-tendency." class="section level2 hasAnchor" number="5.4">
<h2><span class="header-section-number">5.4</span> Measuring our sample distribution: central tendency.<a href="stats.html#measuring-our-sample-distribution-central-tendency." class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>When we take a sample of a population, there are a few things we will want to measure about the distribution of values: where is the middle, how variable is it, and is it skewed to one side or another?</p>
<p>The first of these, “where is the middle?” is addressed with measures of central tendency. We will discuss three possible ways to measure this. The mean, median, and weighted mean.</p>
<p>To explain the importance of choosing between the mean and median, we will first import some discharge data. Read in the PINE discharge data.</p>
<div class="sourceCode" id="cb85"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb85-1"><a href="stats.html#cb85-1" aria-hidden="true" tabindex="-1"></a>pineQ <span class="ot"><-</span> <span class="fu">read_csv</span>(<span class="st">"PINE_Jan-Mar_2010.csv"</span>)</span></code></pre></div>
<pre><code>## Rows: 2160 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): StationID, surrogate
## dbl (5): cfs, year, quarter, month, day
## dttm (1): datetime
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.</code></pre>
<p>To find the mean (average), you just sum up all the values in your sample and divide by the number of values.</p>
<p>To find the median, you put the values IN ORDER, and choose the middle value. The middle value is the one where there are the same number of values higher than that value as there are values lower than it.</p>
<p>Because it uses the order of the values rather than just the values themselves, the median is resistant to skewed distributions. This means it is less effected by very large or very small values compared to most values in the sample data.</p>
<p>Let’s look at our normal distribution from earlier (ExNorm) compared to the Pine watershed discharge (pineQ)</p>
<p>Note that distributions like pineQ, that are positively skewed, are very common in environmental data.</p>
<div class="sourceCode" id="cb87"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb87-1"><a href="stats.html#cb87-1" aria-hidden="true" tabindex="-1"></a><span class="co">#Calculate mean and median for cfs in pineQ and values in ExNorm</span></span>
<span id="cb87-2"><a href="stats.html#cb87-2" aria-hidden="true" tabindex="-1"></a>pineMean <span class="ot"><-</span> <span class="fu">mean</span>(pineQ<span class="sc">$</span>cfs)</span>
<span id="cb87-3"><a href="stats.html#cb87-3" aria-hidden="true" tabindex="-1"></a>pineMedian <span class="ot"><-</span> <span class="fu">median</span>(pineQ<span class="sc">$</span>cfs)</span>
<span id="cb87-4"><a href="stats.html#cb87-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb87-5"><a href="stats.html#cb87-5" aria-hidden="true" tabindex="-1"></a>xmean <span class="ot"><-</span> <span class="fu">mean</span>(ExNorm<span class="sc">$</span>value)</span>
<span id="cb87-6"><a href="stats.html#cb87-6" aria-hidden="true" tabindex="-1"></a>xmedian <span class="ot"><-</span> <span class="fu">median</span>(ExNorm<span class="sc">$</span>value)</span>
<span id="cb87-7"><a href="stats.html#cb87-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb87-8"><a href="stats.html#cb87-8" aria-hidden="true" tabindex="-1"></a><span class="co">#plot mean and median on the ExNorm distribution</span></span>
<span id="cb87-9"><a href="stats.html#cb87-9" aria-hidden="true" tabindex="-1"></a>Ex <span class="ot"><-</span> ExNorm <span class="sc">%>%</span> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value)) <span class="sc">+</span></span>
<span id="cb87-10"><a href="stats.html#cb87-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>()<span class="sc">+</span></span>
<span id="cb87-11"><a href="stats.html#cb87-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept =</span> xmean, <span class="at">color =</span> <span class="st">"red"</span>)<span class="sc">+</span></span>
<span id="cb87-12"><a href="stats.html#cb87-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept =</span> xmedian, <span class="at">color =</span> <span class="st">"blue"</span>)</span>
<span id="cb87-13"><a href="stats.html#cb87-13" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb87-14"><a href="stats.html#cb87-14" aria-hidden="true" tabindex="-1"></a><span class="co">#plot mean and median on the pineQ discharge histogram</span></span>
<span id="cb87-15"><a href="stats.html#cb87-15" aria-hidden="true" tabindex="-1"></a>PineP <span class="ot"><-</span> pineQ <span class="sc">%>%</span> <span class="fu">ggplot</span>(<span class="fu">aes</span>(cfs)) <span class="sc">+</span></span>
<span id="cb87-16"><a href="stats.html#cb87-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>()<span class="sc">+</span></span>
<span id="cb87-17"><a href="stats.html#cb87-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept =</span> pineMean, <span class="at">color =</span> <span class="st">"red"</span>)<span class="sc">+</span></span>
<span id="cb87-18"><a href="stats.html#cb87-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_vline</span>(<span class="at">xintercept =</span> pineMedian, <span class="at">color =</span> <span class="st">"blue"</span>)</span>
<span id="cb87-19"><a href="stats.html#cb87-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb87-20"><a href="stats.html#cb87-20" aria-hidden="true" tabindex="-1"></a>Ex <span class="sc">/</span> PineP </span></code></pre></div>
<pre><code>## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.</code></pre>
<p><img src="Hydroinformatics_Bookdown_files/figure-html/unnamed-chunk-46-1.png" width="672" /></p>
<div id="so-whats-a-weighted-average" class="section level3 hasAnchor" number="5.4.1">
<h3><span class="header-section-number">5.4.1</span> So what’s a weighted average?<a href="stats.html#so-whats-a-weighted-average" class="anchor-section" aria-label="Anchor link to header"></a></h3>
<p>When you compute a standard mean or median, you are giving equal weight to each measurement. Adding up all the values in a sample and dividing by the number of samples is the same as multiplying each value by 1/# of samples. For instance if you had ten samples, to calculate the mean you would add them up and divide by 10. This is the same as multiplying each value by 1/10 and then adding them up. Each value is equally weighted at 1/10.</p>
<p>There are certain situations in which this is not the ideal way to calculate an average. A common one in hydrology is that you have samples that are supposed to represent different portions of an area. One sample may be taken to measure a forest type that takes up 100 ha of a watershed while another sample represents a forest type that only takes up 4 ha. You may not want to simply average those values!</p>
<p>Another example is precipitation gages. In the image below, you see there are 5 rain gages. To get a precipitation number for the watershed, we could just average them, or we could assume they represent an area of the watershed and then weight their values by the area they represent. One method of designating the areas is by using Theissen polygons (the middle watershed). Another method of weighting is isohyetal contours, but we won’t worry about that for now!</p>
<p>In the weighted situation, we find the average by multiplying each precipitation values by the proportion of the watershed it represents, shown by the Thiessen polygons, and then add them all together. Let’s do an example.</p>
<p><img src="images/theissen.png" title="Different types of area averaging" alt="Different types of area averaging" />source: <a href="https://edx.hydrolearn.org/assets/courseware/v1/e5dc65098f1e8c5faacae0e171e28ccf/asset-v1:HydroLearn+HydroLearn401+2019_S2+type@asset+block/l2_image004.png" class="uri">https://edx.hydrolearn.org/assets/courseware/v1/e5dc65098f1e8c5faacae0e171e28ccf/asset-v1:HydroLearn+HydroLearn401+2019_S2+type@asset+block/l2_image004.png</a></p>
<p>The precip values for the watershed above are 4.5, 5.5, 5.8, 4.7, and 3.0</p>
<p>We will assume the proportions of the watershed that each gauge represents are 0.20, 0.15, 0.40, 0.15, 0.10, respectively (or 20%, 15%, 40%, 15%, 10%)</p>
<p>Write some code to compute the regular mean precip from the values, and then the weighted mean.</p>
<div class="sourceCode" id="cb89"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb89-1"><a href="stats.html#cb89-1" aria-hidden="true" tabindex="-1"></a>precip <span class="ot"><-</span> <span class="fu">c</span>(<span class="fl">4.5</span>, <span class="fl">5.5</span>, <span class="fl">5.8</span>, <span class="fl">4.7</span>, <span class="fl">3.0</span>)</span>
<span id="cb89-2"><a href="stats.html#cb89-2" aria-hidden="true" tabindex="-1"></a>weights <span class="ot"><-</span> <span class="fu">c</span>(<span class="fl">0.2</span>, <span class="fl">0.15</span>, <span class="fl">0.4</span>, <span class="fl">0.15</span>, <span class="fl">0.1</span>)</span>
<span id="cb89-3"><a href="stats.html#cb89-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb89-4"><a href="stats.html#cb89-4" aria-hidden="true" tabindex="-1"></a><span class="fu">mean</span>(precip)</span></code></pre></div>
<pre><code>## [1] 4.7</code></pre>
<div class="sourceCode" id="cb91"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb91-1"><a href="stats.html#cb91-1" aria-hidden="true" tabindex="-1"></a><span class="fu">sum</span>(precip <span class="sc">*</span> weights)</span></code></pre></div>
<pre><code>## [1] 5.05</code></pre>
</div>
</div>
<div id="measures-of-variability" class="section level2 hasAnchor" number="5.5">
<h2><span class="header-section-number">5.5</span> Measures of variability<a href="stats.html#measures-of-variability" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>Measures of variability allow us to measure the width of our sample data histogram or pdf. If all the values in our sample are close together, we would have small measures of variability, and a pointy pdf/histogram. If they vary more, we would have larger measures of variability and a broad pdf/histogram.</p>
<p>We will explore four measures of variability:</p>
<div id="variance" class="section level4 hasAnchor" number="5.5.0.1">
<h4><span class="header-section-number">5.5.0.1</span> Variance:<a href="stats.html#variance" class="anchor-section" aria-label="Anchor link to header"></a></h4>
<p>Sum of the squared difference of each value from the mean divided by the number of samples minus 1. var()</p>
<p><img src="images/Screen%20Shot%202021-01-25%20at%2010.29.45%20AM.png" alt="Formula for variance (from USGS statistics book linked)" />(<a href="https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf" class="uri">https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf</a>) source: <a href="https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf" class="uri">https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf</a></p>
</div>
<div id="standard-deviation" class="section level4 hasAnchor" number="5.5.0.2">
<h4><span class="header-section-number">5.5.0.2</span> Standard deviation:<a href="stats.html#standard-deviation" class="anchor-section" aria-label="Anchor link to header"></a></h4>
<p>The square root of the variance sd()</p>
<p>**Both variance and standard deviation are sensitive to outliers.</p>
</div>
<div id="cv-coefficient-of-variation" class="section level4 hasAnchor" number="5.5.0.3">
<h4><span class="header-section-number">5.5.0.3</span> CV: Coefficient of Variation<a href="stats.html#cv-coefficient-of-variation" class="anchor-section" aria-label="Anchor link to header"></a></h4>
<p>CV is simply the standard deviation divided by the mean of the data. Because you divide by the mean, CV is dimensionless. This allows you to use it to compare the variation in samples with very different magnitudes.</p>
</div>
<div id="iqr-interquartile-range" class="section level4 hasAnchor" number="5.5.0.4">
<h4><span class="header-section-number">5.5.0.4</span> IQR: Interquartile Range<a href="stats.html#iqr-interquartile-range" class="anchor-section" aria-label="Anchor link to header"></a></h4>
<p>IQR is resistant to outliers because it works like a median. It measures the range of the middle 50% of the data in your distribution. So the IQR is the difference between the value between the 75th and 25th percentiles of your data, where the 75th percentile means 75% of the data is BELOW that value and the 25th percentile means 25% is below that value. Using the same vocabulary, the median is the same as the 50th percentile of the data.</p>
<p>If you ask R for the QUANTILES of your sample data, it will give you the values at which 0%, 25%, 50%, 75%, and 100% of the data are below. These are the 1,2,3,4, and 5th quantiles. Therefore, the IQR is the difference between the 4th and 2nd quantile.</p>
<p>Okay, code time.</p>
<p>First, let’s explore how changing the variability of a distribution changes the shape of it’s distribution. Create a plot a random normal distribution using rnorm() and set sd to different numbers. Make the mean of the distribution 0, the sample size 300, and the standard deviation 1 to start. Then increase the standard deviation incrementally to 10 and see what happens. Make the limits of the x axis on the plot -30 to 30.</p>
<div class="sourceCode" id="cb93"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb93-1"><a href="stats.html#cb93-1" aria-hidden="true" tabindex="-1"></a><span class="fu">rnorm</span>(<span class="dv">300</span>, <span class="at">mean =</span> <span class="dv">0</span>, <span class="at">sd =</span> <span class="dv">1</span>) <span class="sc">%>%</span> as_tibble <span class="sc">%>%</span></span>
<span id="cb93-2"><a href="stats.html#cb93-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(value))<span class="sc">+</span></span>
<span id="cb93-3"><a href="stats.html#cb93-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_density</span>()<span class="sc">+</span></span>
<span id="cb93-4"><a href="stats.html#cb93-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">xlim</span>(<span class="fu">c</span>(<span class="sc">-</span><span class="dv">30</span>,<span class="dv">30</span>))</span></code></pre></div>
<p><img src="Hydroinformatics_Bookdown_files/figure-html/unnamed-chunk-48-1.png" width="672" /></p>
<p>Now let’s calculate the standard deviation, variance, coefficient of variation, and IQR of the Pine discharge data.</p>
<div class="sourceCode" id="cb94"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb94-1"><a href="stats.html#cb94-1" aria-hidden="true" tabindex="-1"></a><span class="co">#standard deviation</span></span>
<span id="cb94-2"><a href="stats.html#cb94-2" aria-hidden="true" tabindex="-1"></a><span class="fu">sd</span>(pineQ<span class="sc">$</span>cfs)</span></code></pre></div>
<pre><code>## [1] 84.47625</code></pre>
<div class="sourceCode" id="cb96"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb96-1"><a href="stats.html#cb96-1" aria-hidden="true" tabindex="-1"></a><span class="co">#variance</span></span>
<span id="cb96-2"><a href="stats.html#cb96-2" aria-hidden="true" tabindex="-1"></a><span class="fu">var</span>(pineQ<span class="sc">$</span>cfs)</span></code></pre></div>
<pre><code>## [1] 7136.237</code></pre>
<div class="sourceCode" id="cb98"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb98-1"><a href="stats.html#cb98-1" aria-hidden="true" tabindex="-1"></a><span class="co">#coefficient of variation</span></span>
<span id="cb98-2"><a href="stats.html#cb98-2" aria-hidden="true" tabindex="-1"></a><span class="fu">sd</span>(pineQ<span class="sc">$</span>cfs)<span class="sc">/</span><span class="fu">mean</span>(pineQ<span class="sc">$</span>cfs)</span></code></pre></div>
<pre><code>## [1] 2.800221</code></pre>
<div class="sourceCode" id="cb100"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb100-1"><a href="stats.html#cb100-1" aria-hidden="true" tabindex="-1"></a><span class="co">#IQR using the IQR funciton</span></span>
<span id="cb100-2"><a href="stats.html#cb100-2" aria-hidden="true" tabindex="-1"></a><span class="fu">IQR</span>(pineQ<span class="sc">$</span>cfs)</span></code></pre></div>
<pre><code>## [1] 8.1325</code></pre>
<div class="sourceCode" id="cb102"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb102-1"><a href="stats.html#cb102-1" aria-hidden="true" tabindex="-1"></a><span class="co">#IQR using the quantile function</span></span>
<span id="cb102-2"><a href="stats.html#cb102-2" aria-hidden="true" tabindex="-1"></a>quants <span class="ot"><-</span> <span class="fu">quantile</span>(pineQ<span class="sc">$</span>cfs)</span>
<span id="cb102-3"><a href="stats.html#cb102-3" aria-hidden="true" tabindex="-1"></a>quants[<span class="dv">4</span>] <span class="sc">-</span> quants[<span class="dv">2</span>]</span></code></pre></div>
<pre><code>## 75%
## 8.1325</code></pre>
</div>
<div id="what-about-how-lopsided-the-distribution-is" class="section level4 hasAnchor" number="5.5.0.5">
<h4><span class="header-section-number">5.5.0.5</span> What about how lopsided the distribution is?<a href="stats.html#what-about-how-lopsided-the-distribution-is" class="anchor-section" aria-label="Anchor link to header"></a></h4>
<p>There are several ways to measure this as well, but we are just going to look at one: The Quartile skew. The quartile skew is the difference between the upper quartiles (50th-75th) and the lower quartiles (25th-50th) divided by the IQR (75th-25th).</p>
<p><img src="images/Screen%20Shot%202021-01-25%20at%2011.27.14%20AM.png" alt="Quartile skew from USGS Stats Book linked above" /> source: <a href="https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf" class="uri">https://pubs.usgs.gov/tm/04/a03/tm4a3.pdf</a></p>
<p>Let’s look at the quartile skew of the two distributions we’ve been measuring. Calculate it for the pineQ discharge data and the random normal distribution we generated.</p>
<p>Which one is more skewed?</p>
<div class="sourceCode" id="cb104"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb104-1"><a href="stats.html#cb104-1" aria-hidden="true" tabindex="-1"></a>quantsP <span class="ot"><-</span> <span class="fu">quantile</span>(pineQ<span class="sc">$</span>cfs)</span>
<span id="cb104-2"><a href="stats.html#cb104-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb104-3"><a href="stats.html#cb104-3" aria-hidden="true" tabindex="-1"></a>((quantsP[<span class="dv">3</span>]<span class="sc">-</span>quantsP[<span class="dv">2</span>]) <span class="sc">-</span> (quantsP[<span class="dv">2</span>] <span class="sc">-</span> quantsP[<span class="dv">1</span>])) <span class="sc">/</span> quantsP[<span class="dv">3</span>] <span class="sc">-</span> quantsP[<span class="dv">1</span>]</span></code></pre></div>
<pre><code>## 50%
## -4.837233</code></pre>
<div class="sourceCode" id="cb106"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb106-1"><a href="stats.html#cb106-1" aria-hidden="true" tabindex="-1"></a>quantsX <span class="ot"><-</span> <span class="fu">quantile</span>(ExNorm<span class="sc">$</span>value)</span>
<span id="cb106-2"><a href="stats.html#cb106-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb106-3"><a href="stats.html#cb106-3" aria-hidden="true" tabindex="-1"></a>((quantsX[<span class="dv">3</span>]<span class="sc">-</span>quantsX[<span class="dv">2</span>]) <span class="sc">-</span> (quantsX[<span class="dv">2</span>] <span class="sc">-</span> quantsX[<span class="dv">1</span>])) <span class="sc">/</span> quantsX[<span class="dv">3</span>] <span class="sc">-</span> quantsX[<span class="dv">1</span>]</span></code></pre></div>
<pre><code>## 50%
## -2.344671</code></pre>
</div>
</div>
<div id="what-is-a-normal-distribution-and-how-can-we-determine-if-we-have-one" class="section level2 hasAnchor" number="5.6">
<h2><span class="header-section-number">5.6</span> What is a normal distribution and how can we determine if we have one?<a href="stats.html#what-is-a-normal-distribution-and-how-can-we-determine-if-we-have-one" class="anchor-section" aria-label="Anchor link to header"></a></h2>
<p>The distribution we generated with rnorm() is a normal distribution. The distribution of pineQ discharge is not normal. Now that we’ve looked at different ways to characterize distributions, we have the vocabulary to describe why.</p>
<p><strong>Normal distributions:</strong></p>
<ul>
<li>mean = median, half values to the right, half to the left</li>
<li>symmetric (not skewed)</li>
<li>single peak</li>
</ul>
<p>Many statistical tests require that the distribution of the data you put into them is normally distributed. BE CAREFUL! There are also tests that use ranked data. Similar to how the median is resistant to outliers, these rank-based tests are resistant to non-normal data. Two popular ones are Kruskal-Wallis and Wilcoxon rank-sum.</p>
<p>But how far off can you be before you don’t consider a distribution normal? Seems like a judgement call!</p>
<p>R to the rescue! There is a built in test for normality called shapiro.test(), which performs the Shapiro-Wilk test of normality. The hypothesis this test tests is “The distribution is normal.” So if this function returns a p-value less than 0.05, you reject that hypothesis and your function is NOT normal.</p>
<p>You can also make a quantile-quantile plot. A straight line on this plot indicates a normal distribution, a non-straight line indicates it is not normal.</p>
<div class="sourceCode" id="cb108"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb108-1"><a href="stats.html#cb108-1" aria-hidden="true" tabindex="-1"></a><span class="fu">shapiro.test</span>(pineQ<span class="sc">$</span>cfs)</span></code></pre></div>
<pre><code>##
## Shapiro-Wilk normality test
##
## data: pineQ$cfs
## W = 0.27155, p-value < 2.2e-16</code></pre>
<div class="sourceCode" id="cb110"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb110-1"><a href="stats.html#cb110-1" aria-hidden="true" tabindex="-1"></a><span class="fu">qqnorm</span>(pineQ<span class="sc">$</span>cfs)</span></code></pre></div>
<p><img src="Hydroinformatics_Bookdown_files/figure-html/unnamed-chunk-51-1.png" width="672" /></p>
</div>
</div>
</section>
</div>
</div>
</div>
<a href="introactivity.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>