b:head_first_statistics:using_the_normal_distribution
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
b:head_first_statistics:using_the_normal_distribution [2022/10/27 22:14] – [Exercise] hkimscil | b:head_first_statistics:using_the_normal_distribution [2024/10/28 08:09] (current) – […then squash the width] hkimscil | ||
---|---|---|---|
Line 88: | Line 88: | ||
===== So how do we find normal probabilities? | ===== So how do we find normal probabilities? | ||
+ | 평균이 0 이고 표준편차가 1일 Normal distribution 에서의 probabilities는 아래의 PDF 파일과 같이 구해 놓은 값이 있다 | ||
+ | (R을 이용하지 않는다면). [[https:// | ||
+ | 평균과 표준편차 값이 0, 1이 아닌 다른 값을 같는 분포는 0, 1 이 되도록 변환한 후에 probability를 구한다 (표준점수화). | ||
+ | |||
+ | |||
{{: | {{: | ||
Line 132: | Line 137: | ||
z & = & \displaystyle \frac {x - \mu}{\sigma} \\ | z & = & \displaystyle \frac {x - \mu}{\sigma} \\ | ||
& = & \frac {64-71} {4.5} \\ | & = & \frac {64-71} {4.5} \\ | ||
- | & = & 1.56 | + | & = & - 1.56 |
\end{eqnarray*} | \end{eqnarray*} | ||
- | 따라서, 표준점수를 1.56을 가지고 표준점수 테이블에서 1.56보다 큰 부분의 면적을 구한것을 참조하면 된다. | + | 따라서, 표준점수를 |
- | < | + | < |
- | > scale(a) | + | > 1 - pnorm(-1.56) |
- | [,1] | + | [1] 0.9406201 |
- | [1,] -1.70622042 | + | > pnorm(-1.56, lower.tail = FALSE) |
- | [2,] -1.67175132 | + | [1] 0.9406201 |
- | [3,] -1.63728222 | + | > pnorm(64, 71, sqrt(20.25), lower.tail = FALSE) |
- | [4,] -1.60281312 | + | [1] 0.9400931 |
- | | + | > |
- | [6,] -1.53387492 | + | </ |
- | [7,] -1.49940582 | + | |
- | [8,] -1.46493672 | + | |
- | [9,] -1.43046762 | + | |
- | [10,] -1.39599852 | + | |
- | [11,] -1.36152943 | + | |
- | [12,] -1.32706033 | + | |
- | [13,] -1.29259123 | + | |
- | [14,] -1.25812213 | + | |
- | [15,] -1.22365303 | + | |
- | [16,] -1.18918393 | + | |
- | [17,] -1.15471483 | + | |
- | [18,] -1.12024573 | + | |
- | [19,] -1.08577663 | + | |
- | [20,] -1.05130753 | + | |
- | [21,] -1.01683843 | + | |
- | [22,] -0.98236933 | + | |
- | [23,] -0.94790023 | + | |
- | [24,] -0.91343113 | + | |
- | [25,] -0.87896203 | + | |
- | [26,] -0.84449293 | + | |
- | [27,] -0.81002384 | + | |
- | [28,] -0.77555474 | + | |
- | [29,] -0.74108564 | + | |
- | [30,] -0.70661654 | + | |
- | [31,] -0.67214744 | + | |
- | [32,] -0.63767834 | + | |
- | [33,] -0.60320924 | + | |
- | [34,] -0.56874014 | + | |
- | [35,] -0.53427104 | + | |
- | [36,] -0.49980194 | + | |
- | [37,] -0.46533284 | + | |
- | [38,] -0.43086374 | + | |
- | [39,] -0.39639464 | + | |
- | [40,] -0.36192554 | + | |
- | [41,] -0.32745644 | + | |
- | [42,] -0.29298734 | + | |
- | [43,] -0.25851825 | + | |
- | [44,] -0.22404915 | + | |
- | [45,] -0.18958005 | + | |
- | [46,] -0.15511095 | + | |
- | [47,] -0.12064185 | + | |
- | [48,] -0.08617275 | + | |
- | [49,] -0.05170365 | + | |
- | [50,] -0.01723455 | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | [64,] 0.46533284 | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | [71,] 0.70661654 | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | [100, | + | |
- | attr(," | + | |
- | [1] 50.5 | + | |
- | attr(," | + | |
- | [1] 29.01149 | + | |
- | > aa <- scale(a) | + | |
- | > mean(aa) | + | |
- | [1] 0 | + | |
- | > sd(aa) | + | |
- | [1] 1 | + | |
- | > </ | + | |
==== exercise ==== | ==== exercise ==== | ||
Line 288: | Line 189: | ||
===== Exercise ===== | ===== Exercise ===== | ||
Julie with 5" heels = 64 + 5 = 69 | Julie with 5" heels = 64 + 5 = 69 | ||
+ | Remember X ~ N(71, 20.25) | ||
+ | mean = 71 | ||
+ | variance = 20.25 | ||
+ | sd = 4.5 | ||
+ | z = (71-69)/4.5 | ||
z score = -0.44 | z score = -0.44 | ||
Line 359: | Line 265: | ||
< | < | ||
+ | Mean <- 100 | ||
+ | Sd <- 10 | ||
- | x <- seq(-4,4, length=100) | + | # X grid for non-standard normal distribution |
- | y <- dnorm(x) | + | x <- seq(-4, 4, length = 100) * Sd + Mean |
- | plot(x,y, type=" | + | |
+ | # Density function | ||
+ | f <- dnorm(x, Mean, Sd) | ||
+ | |||
+ | plot(x, f, type = " | ||
+ | abline(v = Mean) # Vertical line on the mean | ||
</ | </ | ||
- | {{: | ||
- | < | ||
- | # Children' | ||
- | # mean of 100 and a standard deviation of 15. What | ||
- | # proportion of children are expected to have an IQ between | ||
- | # 80 and 120? | ||
- | mean=100; sd=15 | + | {{: |
- | lb=80; ub=120 | + | |
- | x <- seq(-4, | + | <code> |
- | hx <- dnorm(x,mean,sd) | + | # mean: mean of the Normal variable |
+ | # sd: standard deviation of the Normal variable | ||
+ | # lb: lower bound of the area | ||
+ | # ub: upper bound of the area | ||
+ | # acolor: color of the area | ||
+ | # ...: additional arguments to be passed to lines function | ||
- | plot(x, hx, type=" | + | normal_area <- function(mean = 0, sd = 1, lb, ub, acolor |
- | main=" | + | x <- seq(mean - 3 * sd, mean + 3 * sd, length |
+ | |||
+ | if (missing(lb)) { | ||
+ | lb <- min(x) | ||
+ | } | ||
+ | if (missing(ub)) { | ||
+ | ub <- max(x) | ||
+ | } | ||
- | i <- x >= lb & x <= ub | + | x2 <- seq(lb, ub, length = 100) |
- | lines(x, hx) | + | plot(x, dnorm(x, mean, sd), type = " |
- | polygon(c(lb, | + | |
+ | y <- dnorm(x2, mean, sd) | ||
+ | | ||
+ | lines(x, dnorm(x, mean, sd), type = "l", ...) | ||
+ | } | ||
+ | </ | ||
- | area <- pnorm(ub, mean, sd) - pnorm(lb, mean, sd) | + | <code> |
- | result | + | normal_area(mean = 0, sd = 1, lb = -1, ub = 2, lwd = 2) |
- | | + | </ |
- | mtext(result,3) | + | {{: |
- | axis(1, at=seq(40, 160, 20), pos=0) | + | < |
+ | pnorm(2) | ||
+ | pnorm(-1) | ||
+ | pnorm(2)-pnorm(-1) | ||
+ | ar <- round(pnorm(2)-pnorm(-1),3) | ||
+ | </code> | ||
+ | < | ||
+ | > pnorm(2) | ||
+ | [1] 0.9772499 | ||
+ | > pnorm(-1) | ||
+ | [1] 0.1586553 | ||
+ | > pnorm(2)-pnorm(-1) | ||
+ | [1] 0.8185946 | ||
+ | > ar <- round(pnorm(2)-pnorm(-1),3) | ||
+ | > | ||
+ | </ | ||
+ | < | ||
+ | m.s <- 100 | ||
+ | sd.s <- 15 | ||
+ | lb <- 80 | ||
+ | ub <- 110 | ||
+ | normal_area(mean = m.s, sd = sd.s, lb = lb, ub = ub, lwd = 2) | ||
+ | ar <- round(pnorm(ub, m.s, sd.s)-pnorm(lb, m.s, sd.s),3) | ||
+ | text(m.s, .01, ar) | ||
+ | </ | ||
+ | {{: | ||
+ | < | ||
+ | m.s <- 100 | ||
+ | sd.s <- 15 | ||
+ | lb <- m.s - sd.s | ||
+ | ub <- m.s + sd.s | ||
+ | normal_area(mean = m.s, sd = sd.s, lb = lb, ub = ub, lwd = 2) | ||
+ | ar <- round(pnorm(ub, m.s, sd.s)-pnorm(lb, m.s, sd.s),3) | ||
+ | text(m.s, .01, ar) | ||
</ | </ | ||
- | {{: | ||
</ | </ | ||
===== Headline ===== | ===== Headline ===== | ||
Line 833: | Line 787: | ||
</ | </ | ||
+ | 위는 아래와 같음을 이해해야 한다 | ||
+ | < | ||
+ | > sum(dbinom(c(0: | ||
+ | [1] 0.387207 | ||
+ | > | ||
+ | </ | ||
</ | </ | ||
Line 871: | Line 831: | ||
> pnorm(-0.29) | > pnorm(-0.29) | ||
[1] 0.3859081 | [1] 0.3859081 | ||
+ | |||
+ | # the below is the same as the above | ||
+ | > n <- 12 | ||
+ | > p <- 1/2 | ||
+ | > q <- 1-p | ||
+ | > pnorm(5.5, n*p, sqrt(n*p*q)) | ||
+ | [1] 0.386415 | ||
+ | > | ||
</ | </ | ||
b/head_first_statistics/using_the_normal_distribution.1666876452.txt.gz · Last modified: 2022/10/27 22:14 by hkimscil