User Tools

Site Tools


b:head_first_statistics:using_the_normal_distribution

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
b:head_first_statistics:using_the_normal_distribution [2022/10/27 22:32] – [Exercise] hkimscilb:head_first_statistics:using_the_normal_distribution [2023/11/01 08:28] – [When to approximate the binomial distribution with the normal] hkimscil
Line 288: Line 288:
 ===== 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 375: Line 380:
  
 <code> <code>
-# Children's IQ scores are normally distributed with a +mean: mean of the Normal variable 
-# mean of 100 and a standard deviation of 15. What +# sd: standard deviation of the Normal variable 
-proportion of children are expected to have an IQ between +lb: lower bound of the area 
-80 and 120?+ub: upper bound of the area 
 +# acolor: color of the area 
 +# ...: additional arguments to be passed to lines function
  
-mean=100; sd=15 +normal_area <- function(mean = 0, sd = 1, lbub, acolor "lightgray", ...) { 
-lb=80; ub=120+    x <- seq(mean - 3 * sd, mean + 3 * sd, length = 100)  
 +     
 +    if (missing(lb)) { 
 +       lb <- min(x) 
 +    } 
 +    if (missing(ub)) { 
 +        ub <- max(x) 
 +    }
  
-<- seq(-4,4,length=100)*sd + mean +    x2 <- seq(lbub, length = 100)     
-hx <- dnorm(x,mean,sd)+    plot(x, dnorm(x, mean, sd), type = "n", ylab = ""
 +    
 +    <- dnorm(x2, mean, sd) 
 +    polygon(c(lb, x2, ub), c(0, y, 0), col = acolor) 
 +    lines(x, dnorm(x, mean, sd), type = "l", ...) 
 +
 +</code>
  
-plot(x, hx, type="n"xlab="IQ Values"ylab="", +<code> 
-     main="Normal Distribution"axes=FALSE+normal_area(mean 0sd 1lb -1ub 2lwd 2
- +</code> 
-<- x >= lb & x <= ub +{{:b:head_first_statistics:pasted:20221027-224243.png?500}} 
-lines(x, hx+<code
-polygon(c(lb,x[i],ub), c(0,hx[i],0), col="red"+pnorm(2
- +pnorm(-1) 
-area <- pnorm(ub, mean, sd) - pnorm(lb, mean, sd) +pnorm(2)-pnorm(-1) 
-result <- paste("P(",lb,"IQ <",ub,"=", +ar <- round(pnorm(2)-pnorm(-1),3) 
-                signif(areadigits=3)+</code> 
-mtext(result,3) +<code> 
-axis(1at=seq(4016020), pos=0)+> pnorm(2) 
 +[10.9772499 
 +> pnorm(-1) 
 +[1] 0.1586553 
 +> pnorm(2)-pnorm(-1) 
 +[1] 0.8185946 
 +> ar <- round(pnorm(2)-pnorm(-1),3
 + 
 +</code> 
 +<code> 
 +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.01ar) 
 +</code> 
 +{{:b:head_first_statistics:pasted:20221027-225952.png?500}} 
 +<code> 
 +m.s <- 100 
 +sd.s <- 15 
 +lb <- m.s - sd.s 
 +ub <- m.s + sd.s 
 +normal_area(mean = m.ssd sd.slb = lbub ub, lwd = 2
 +ar <- round(pnorm(ubm.s, sd.s)-pnorm(lbm.ssd.s),3) 
 +text(m.s.01, ar)
 </code> </code>
-{{:b:head_first_statistics:pasted:20221027-215953.png?400}} 
 </WRAP> </WRAP>
 ===== Headline ===== ===== Headline =====
Line 841: Line 886:
 </code> </code>
  
 +위는 아래와 같음을 이해해야 한다
 +<code>
 +> sum(dbinom(c(1:5),12,1/2))
 +[1] 0.3869629
 +
 +</code>
 </WRAP> </WRAP>
  
Line 879: Line 930:
 > 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
 +
 </code> </code>
  
b/head_first_statistics/using_the_normal_distribution.txt · Last modified: 2023/11/01 08:29 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki