diff --git a/applied_statistics.pdf b/applied_statistics.pdf index 9c1d837..3e68329 100644 Binary files a/applied_statistics.pdf and b/applied_statistics.pdf differ diff --git a/data-and-programming.html b/data-and-programming.html index 278389c..dc696fa 100644 --- a/data-and-programming.html +++ b/data-and-programming.html @@ -1400,11 +1400,11 @@
(test_sample = rnorm(n = 10, mean = 2, sd = 5))
-## [1] 5.2152952 -0.4088894 10.2547341 3.1708948 3.2387809 7.9702264
-## [7] -0.1896785 -1.8623121 0.9840689 4.1656073
+## [1] 0.7422609 -2.3875606 -2.7494766 6.3362568 10.9520595 5.6211080
+## [7] 3.3890245 -1.3335695 -5.9733504 -0.6340839
standardize(x = test_sample)
## [1] 0.511109876 -0.954447075 1.824293080 -0.021622507 -0.003932669
-## [6] 1.228993240 -0.897324822 -1.333181759 -0.591468277 0.237580914
+## [1] -0.1278914 -0.7399306 -0.8107035 0.9660191 1.8686431 0.8261711
+## [7] 0.3896854 -0.5338217 -1.4411347 -0.3970367
This function could be written much more succinctly, simply performing all the operations on one line and immediately returning the result, without storing any of the intermediate results.
= function(x) {
standardize - mean(x)) / sd(x)
@@ -1441,14 +1441,14 @@ (x 3.3.2 Functions (1 / n) * sum((x - mean(x)) ^ 2)
}
get_var(test_sample)
## [1] 14.72698
+## [1] 26.15054
get_var(test_sample, biased = FALSE)
## [1] 14.72698
+## [1] 26.15054
var(test_sample)
## [1] 14.72698
+## [1] 26.15054
We see the function is working as expected, and when returning the unbiased estimate it matches R
’s built-in function var()
. Finally, let’s examine the biased estimate of \(\sigma^2\).
get_var(test_sample, biased = TRUE)
## [1] 13.25428
+## [1] 23.53549
diff --git a/data-and-programming.md b/data-and-programming.md
index 56927fa..eb24bb2 100644
--- a/data-and-programming.md
+++ b/data-and-programming.md
@@ -1949,8 +1949,8 @@ To test our function, we will take a random sample of size `n = 10` from a norma
```
```
-## [1] 9.3725470 -0.3881391 -0.9134899 5.3499433 1.0275733 -1.1144719
-## [7] -3.4440058 8.1253017 -0.2541194 8.1310970
+## [1] -3.274150 6.033209 3.152851 3.506288 8.875642 -2.937208 4.191324
+## [8] 9.815322 1.466462 7.029886
```
```r
@@ -1958,8 +1958,8 @@ standardize(x = test_sample)
```
```
-## [1] 1.4507231 -0.6367570 -0.7491118 0.5904244 -0.3339841 -0.7920950
-## [7] -1.2903034 1.1839796 -0.6080947 1.1852190
+## [1] -1.58353155 0.50404094 -0.14200237 -0.06272889 1.14157773 -1.50795787
+## [7] 0.09091966 1.35234111 -0.52024695 0.72758818
```
This function could be written much more succinctly, simply performing all the operations on one line and immediately returning the result, without storing any of the intermediate results.
@@ -2061,7 +2061,7 @@ get_var(test_sample)
```
```
-## [1] 21.86331
+## [1] 19.87787
```
```r
@@ -2069,7 +2069,7 @@ get_var(test_sample, biased = FALSE)
```
```
-## [1] 21.86331
+## [1] 19.87787
```
```r
@@ -2077,7 +2077,7 @@ var(test_sample)
```
```
-## [1] 21.86331
+## [1] 19.87787
```
We see the function is working as expected, and when returning the unbiased estimate it matches `R`'s built-in function `var()`. Finally, let's examine the biased estimate of $\sigma^2$.
@@ -2088,7 +2088,7 @@ get_var(test_sample, biased = TRUE)
```
```
-## [1] 19.67698
+## [1] 17.89008
```
diff --git a/index.html b/index.html
index ec32d9f..9698e48 100644
--- a/index.html
+++ b/index.html
@@ -486,7 +486,7 @@ a = 3
b = 4
-sqrt(a ^ 2 + b ^ 2)
+sqrt(a^2 + b^2)
R
output lines, which would appear in the console will begin with ##
. They will generally not be syntax highlighted.
## [1] 5
We use the quantity \(p\) to refer to the number of \(\beta\) parameters in a linear model, not the number of predictors. Don’t worry if you don’t know what this means yet!
@@ -551,6 +551,7 @@rnorm(n = 10, mean = 2, sd = 5)
## [1] -0.1511374 9.5689553 5.8823146 10.8269357 4.1166161 -3.0856548
-## [7] -8.0008763 2.7528093 -11.8899131 2.8837606
+## [1] 12.1043510 3.8159564 7.5306631 -5.5364163 2.8279956 -5.5687766
+## [7] 0.3826921 1.9029218 -0.1358380 0.1182879
These functions exist for many other distributions, including but not limited to: