User Tools

Site Tools


r:probability

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
r:probability [2016/10/19 09:56] hkimscilr:probability [2019/10/04 10:27] (current) – [qt, pt] hkimscil
Line 1: Line 1:
 +====== Normal distribution functions ======
  
 ^ Function  ^ Purpose  ^ ^ Function  ^ Purpose  ^
Line 30: Line 31:
 | Weibull  | weibull  | shape; scale  | | Weibull  | weibull  | shape; scale  |
 | Wilcoxon  | wilcox  | m = number of observations in first sample; \\ n = number of observations in second sample   | | Wilcoxon  | wilcox  | m = number of observations in first sample; \\ n = number of observations in second sample   |
 +===== pnorm, qnorm =====
 +
 +<WRAP info>
 +Normal distribution
 +$ f(x) = \frac{1}{\sigma \sqrt{2\pi}} e^{\frac{-(x-\mu)^2}{2\sigma^2}} $
 +
 +Assume that the test scores of a college entrance exam fits a normal distribution. Furthermore, the mean test score is 72, and the standard deviation is 15.2. What is the percentage of students scoring 84 or more in the exam?
 +
 +<code>> pnorm(72, mean=72, sd=15.2, lower.tail=FALSE)
 +[1] 0.5
 +
 +> pnorm(1.96)
 +[1] 0.9750021
 +
 +> pnorm(1.96)-pnorm(-1.96)
 +[1] 0.9500042
 +
 +> pnorm(c(1.96, -1.96))
 +[1] 0.9750021 0.0249979
 +
 +> pnorm(84, mean=72, sd=15.2, lower.tail=FALSE)
 +[1] .2149176
 +
 +> qnorm(.2149176, mean=72, sd=15.2, lower.tail=FALSE)
 +[1] 84
 +</code></WRAP>
 +===== rnorm =====
 +Random samples from a normal distribution
 +<code>> set.seed(1024)
 +> rnorm(50)
 + [1] -0.778662882 -0.389476396 -2.033798329 -0.982373104  0.247890054
 + [6] -2.103864629 -0.381418049  2.074919838  1.027138407  0.473014228
 +[11] -1.879263193 -1.239189026  1.160418602  0.003671291 -0.095452066
 +[16]  1.795551228 -1.322138481 -0.276086413 -0.743976510 -1.070050125
 +[21] -0.349525474  0.805559661  1.605301660  1.447595754 -0.128302224
 +[26] -0.538926447  0.391586050  0.879217023 -0.824732092  0.732876423
 +[31] -0.664914510  0.360885549  1.011930957 -0.235916848  1.353589893
 +[36] -0.268632965  1.019877368 -0.279706500 -0.618146278 -0.499273059
 +[41] -0.153716777  1.220869694 -0.669570510 -1.209660342  1.024096655
 +[46]  0.603955311 -0.568653469 -0.891303117 -2.525145692  0.589357049</code>
 +
 +
 +===== qt, pt =====
 +
 +<WRAP info>
 +$t = \frac{Z}{\sqrt{\frac{V}{m}}}$
 +<code>> qt(c(0.025, 0.975), df=5)
 +[1] -2.5706  2.5706
 +
 +> qt(c(0.025, 0.975), df=10)
 +[1] -2.228139  2.228139
 +
 +> qt(c(0.025, 0.975), df=20)
 +[1] -2.085963  2.085963
 +
 +> qt(c(0.025, 0.975), df=30)
 +[1] -2.042272  2.042272
 +
 +> qt(c(0.025, 0.975), df=40)
 +[1] -2.021075  2.021075
 +
 +> qt(c(0.025, 0.975), df=50)
 +[1] -2.008559  2.008559
 +
 +. . . . . .
 +
 +> qt(c(0.025, 0.975), df=50000)
 +[1] -1.960011  1.960011
 +
 +</code>
 +</WRAP>
  
 ====== Counting the Number of Combinations ====== ====== Counting the Number of Combinations ======
Line 92: Line 164:
 </code> </code>
  
-<code>> rnorm(3, mean=c(-10,0,+10), sd=1)+ 
 +<code>> rnorm(3, mean=c(-10,0,+10), sd=1) # mean이 각 -10,0,10이고 각 mean의 sd가 1인 경우에, random score를 구할것
 [1] -11.195667   2.615493  10.294831 [1] -11.195667   2.615493  10.294831
 </code> </code>
Line 131: Line 204:
  
 Replacement in random sampling: Specify replace=TRUE to sample with replacement. Replacement in random sampling: Specify replace=TRUE to sample with replacement.
 +
 +<code>> set.seed(121)
 +sample(world.series$year, 10)
 + [1] 1906 1963 1966 1928 1905 1924 1961 1959 1927 1934
 +set.seed(121)
 +sample(world.series$year, 10)
 + [1] 1906 1963 1966 1928 1905 1924 1961 1959 1927 1934
 +</code>
 +
  
 ====== Generating Random Sequences ====== ====== Generating Random Sequences ======
Line 197: Line 279:
 </code> </code>
  
-<code>> qnorm(c(0.025, 0.975))+<code>> pnorm(73, mean=70, sd=3) 
 +[1] 0.8413447 
 +</code> 
 + 
 +<code>> qnorm(c(0.025, 0.975)) # 5% 바깥쪽의 점수는 약 +-2sd 점수인 -2, 2
 [1] -1.959964  1.959964 [1] -1.959964  1.959964
 </code> </code>
Line 216: Line 302:
  
 {{standard_normal_distribution.png|standard_normal_distribution}} {{standard_normal_distribution.png|standard_normal_distribution}}
 +
 +<code>> # The body of the polygon follows the density curve where 1 <= z <= 2
 +> region.x <- x[1 <= x & x <= 2]
 +> region.y <- y[1 <= x & x <= 2]
 +
 +> # We add initial and final segments, which drop down to the Y axis
 +> region.x <- c(region.x[1], region.x, tail(region.x,1))
 +> region.y <- c(          0, region.y,                0)
 +> polygon(region.x, region.y, density=-1, col="red")
 +</code>
 +
 +{{standard_normal_distribution_1-2.png|standard_normal_distribution}}
 +
r/probability.1476840368.txt.gz · Last modified: 2016/10/19 09:56 by hkimscil

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki