PROBABILITY DISTRIBUTION
1-pnorm(12,10,1.5)
## [1] 0.09121122
dnorm(12,10,1.5)
## [1] 0.10934
plot(1:12,dnorm(1:12,1.5),type ='h')
#exponential distribution
pexp(5,0.2)
## [1] 0.6321206
1-pexp(0.8,0.2,5)
## [1] 0.8521438
plot(1:5,pexp(1:5,0.2),type = 'b')
#standard normal
1-dnorm(8,7,1)
## [1] 0.7580293
plot(1:8,1-dnorm(1:8,7),type = 'b')
#weibull distribution
#pdf
dweibull(5,2,1)
## [1] 1.388794e-10
plot(1:5,dweibull(1:5,2,1),type = 'h')
#cdf
pweibull(5,2,1)
## [1] 1
plot(1:5,pweibull(1:5,2,1),type = 'h')
#quantiles
qweibull(0.25,2,1)
## [1] 0.53636
set.seed(12345)
rweibull(10,2,1)
## [1] 0.5720572 0.3642089 0.5226329 0.3477035 0.8855554 1.3392275 1.0600173
## [8] 0.8215027 0.5637900 0.1015682
#binomial distribution
#pmf
dbinom(6,8,0.7)
## [1] 0.2964755
plot(1:6,dbinom(1:6,8,0.7))
#cdf
1-pbinom(6,8,0.7)
## [1] 0.2552983
plot(1:6,1-pbinom(1:6,8,0.7),type = 'h')
#quantiles
w=qbinom(0.75,8,0.7)-qbinom(0.25,8,0.7);w
## [1] 2
set.seed(12345)
rbinom(100,8,0.7)
## [1] 5 4 5 4 6 7 6 6 5 2 8 7 5 8 6 6 6 6 7 3 6 6 3 5 5 6 5 6 7 6 5 8 7 5 6 6 4
## [38] 4 5 7 5 6 4 5 6 6 7 8 8 5 3 4 6 7 5 6 5 7 6 7 5 6 3 5 3 7 3 7 5 3 5 6 6 6
## [75] 8 5 3 5 6 7 4 6 8 8 7 6 4 6 5 7 4 4 7 5 5 6 5 5 7 6
plot(1:100,rbinom(1:100,9,0.7),type = 'h')
#gamma distribution
#pdf
dgamma(3,10,0.25)
## [1] 2.443473e-08
plot(1:3,dgamma(1:3,10,0.25),type = 'h')
#cdf
pgamma(3,10,0.25)
## [1] 7.863361e-09
plot(1:3,pgamma(1:3,10,0.25),type = 'h')
#quantiles
qgamma(0.5,10,0.25)
## [1] 38.67486
qgamma(0.75,10,0.25)
## [1] 47.65538
set.seed(1000)
rgamma(100,10,0.25)
## [1] 32.70279 44.38765 21.82349 28.92137 47.00737 52.87076 22.18200 22.95652
## [9] 49.33444 22.10603 36.52440 25.00415 39.93599 38.30800 16.95651 32.36622
## [17] 24.37790 45.24653 39.97488 38.21471 44.06131 38.56173 44.18324 39.52653
## [25] 37.49598 47.11235 29.78952 57.84921 48.32106 45.21996 35.55448 29.40668
## [33] 26.82785 57.39804 40.32096 37.46324 36.04564 40.88427 39.33846 22.90878
## [41] 35.09851 25.70206 51.62167 44.77435 31.83534 19.13267 23.16938 28.12792
## [49] 31.83128 54.75787 54.17697 32.13379 39.09512 20.21997 27.11791 26.31027
## [57] 46.58572 41.60084 57.05204 36.06087 39.92635 41.86830 21.86599 42.24355
## [65] 53.78302 41.11863 33.71271 56.57356 31.75702 37.18786 39.26601 63.43708
## [73] 57.03251 35.98515 43.91103 36.04429 48.13664 34.99024 48.90158 33.37793
## [81] 46.89527 32.82257 36.61687 39.64896 45.08344 42.33277 39.70701 36.13899
## [89] 54.28543 47.81594 34.51674 40.88805 51.31437 41.68089 28.77300 21.79692
## [97] 34.15618 45.34107 34.13105 54.89288
plot(1:100,rgamma(1:100,10,0.25),type = 'h')
#lognormal distribution
#pdf
dlnorm(5,0,1)
## [1] 0.02185071
plot(1:5,dlnorm(1:5,0,1),type = 'h')
#cdf
plnorm(5,0,1)
## [1] 0.9462397
plot(1:5,plnorm(1:5,0,1),type = 'h')
#quantiles
qlnorm(0.5,0.1)
## [1] 1.105171
set.seed(25)
rlnorm(25,0,1)
## [1] 0.8090993 0.3528927 0.3155912 1.3792384 0.2231012 0.6404826
## [7] 5.6635190 1.6674502 1.1047787 0.9437527 0.1750318 0.2658155
## [13] 0.5781431 0.2330775 1.0862016 2.5283804 0.4883273 2.6179712
## [19] 4.6921204 0.3643051 1.7461456 1.1838615 1.1679603 10.6735075
## [25] 0.2048158
#beta distribution
#pdf
dbeta(2,10,0.5)
## [1] 0
plot(1:2,dbeta(1:2,10,0.5),type='l')
#cdf
pbeta(2,10,0.5)
## [1] 1
plot(1:2,pbeta(1:2,10,0.5),type = 'h')
#quantiles
qbeta(0.5,10,0.5)
## [1] 0.9769486
qbeta(0,10,0.5)
## [1] 0
rbeta(100,10,0.5)
## [1] 0.9974870 0.9613510 0.9816085 0.9415334 0.9850962 0.9989579 0.9783379
## [8] 0.9596831 0.8014826 0.9962607 0.9448847 0.9802931 0.9702328 0.9890107
## [15] 0.8585350 0.9586891 0.9445658 0.9996388 0.9655588 0.8531854 0.9407777
## [22] 0.9992605 0.8648559 0.9557764 0.9681948 0.9666306 0.9880581 0.9782596
## [29] 0.9988812 0.9998814 0.9452927 0.8630627 0.9998655 0.8846322 0.9634338
## [36] 0.8004557 0.9960263 0.9578643 0.8274132 0.9895545 0.9812026 0.9957266
## [43] 0.8847982 0.9990074 0.9995791 0.9914270 0.6918112 0.9273684 0.9997067
## [50] 0.9919953 0.9992773 0.9857529 0.9752212 0.9347065 0.8382648 0.9665175
## [57] 0.9924188 0.9531755 0.8866218 0.7354876 0.9760625 0.9865678 0.9752528
## [64] 0.9167353 0.9402209 0.9732523 0.8556146 0.8558986 0.9144662 0.9652677
## [71] 0.9950599 0.9996951 0.9850906 0.9640445 0.7636201 0.9466924 0.9989587
## [78] 0.9771478 0.9956642 0.9935292 0.9998189 0.8406452 0.8558887 0.9836310
## [85] 0.9627308 0.9811019 0.9981293 0.9954700 0.9975116 0.9826209 0.5735490
## [92] 0.8444917 0.9881197 0.9970236 0.9734368 0.8743810 0.8832367 0.9109390
## [99] 0.8601190 0.9957837
plot(1:100,rbeta(1:100,10,0.25),type='h')
#hypergeometric distribution
#pdf
dhyper(10,45,30,20)
## [1] 0.1193389
plot(1:10,dhyper(1:10,45,30,20),type = 'h')
#cdf
1-phyper(10,45,30,20)
## [1] 0.7886695
plot(1:10,phyper(1:10,45,30,20),type = 'h')
#quantiles
qhyper(0.9,45,30,20)
## [1] 14
set.seed(400)
rhyper(100,45,30,20)
## [1] 14 14 11 13 9 12 13 12 13 13 15 12 10 11 11 12 12 9 13 12 14 11 12 11 15
## [26] 13 12 8 14 14 11 13 13 12 13 9 11 11 14 10 10 12 17 11 12 11 10 13 9 12
## [51] 10 13 10 10 12 13 11 13 13 13 12 12 13 13 11 12 11 12 13 12 13 12 14 12 13
## [76] 12 12 12 13 12 9 14 13 14 10 14 10 11 13 12 13 15 11 13 12 13 15 11 10 11
#discrete uniform distribution
#pdf
dunif(3,0,1)
## [1] 0
plot(1:3,dunif(1:3,0,1),type = 'h')
#cdf
punif(3,0,1)
## [1] 1
plot(1:3,punif(1:3,0,1),type = 'h')
#quantiles
qunif(0.80,0,1)
## [1] 0.8
set.seed(100)
runif(100,0,1)
## [1] 0.30776611 0.25767250 0.55232243 0.05638315 0.46854928 0.48377074
## [7] 0.81240262 0.37032054 0.54655860 0.17026205 0.62499648 0.88216552
## [13] 0.28035384 0.39848790 0.76255108 0.66902171 0.20461216 0.35752485
## [19] 0.35947511 0.69029053 0.53581115 0.71080385 0.53834870 0.74897223
## [25] 0.42010145 0.17142021 0.77030161 0.88195359 0.54909671 0.27772376
## [31] 0.48830599 0.92850507 0.34869198 0.95415771 0.69527414 0.88945354
## [37] 0.18040725 0.62939085 0.98956414 0.13028887 0.33066053 0.86512055
## [43] 0.77758444 0.82730345 0.60332436 0.49123182 0.78035851 0.88422703
## [49] 0.20771390 0.30708590 0.33052985 0.19867907 0.23569430 0.27488666
## [55] 0.59132105 0.25339065 0.12348723 0.22990589 0.59757529 0.21140856
## [61] 0.46370118 0.64710119 0.96057309 0.67639817 0.44514802 0.35777378
## [67] 0.45573146 0.44541398 0.24509259 0.69435071 0.41223704 0.32772587
## [73] 0.57256477 0.96699908 0.66177902 0.62469772 0.85665304 0.77477889
## [79] 0.83402710 0.09151028 0.45952549 0.59939816 0.91972191 0.98282408
## [85] 0.03780258 0.57793740 0.73331417 0.24874240 0.30073652 0.73346670
## [91] 0.90695438 0.20981677 0.35813799 0.44829914 0.90642643 0.38943930
## [97] 0.51745975 0.12523909 0.03014575 0.77180549
#poisson distribution
#pmf
dpois(2,3)
## [1] 0.2240418
plot(1:2,dpois(1:2,3),type = 'h')
#cdf
ppois(6,3)
## [1] 0.9664915
plot(1:6,ppois(1:6,3),type = 'h')
#quantiles
qpois(0.50,3)
## [1] 3
rpois(2,3)
## [1] 2 2
rpois(6,3)
## [1] 0 2 3 4 7 4