R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

#BINOMIAL DISTRIBUTIONS
options(scipen = 999)
dbinom(x=11,size=40,prob=6/10)
## [1] 0.00002417431
#EXPONENTIAL PROBABILITY DISTRIBUTIONS 
#a) randomly selected bulb runs between 3 and 12 months
pexp(12, 1/8)-pexp(3,1/8)
## [1] 0.4641591
#b) 95th percentile
qexp(0.95,1/8)
## [1] 23.96586
#c)prob that a bulb that has lasted 10 months, will last more than 25 months
pexp(25-10,1/8)
## [1] 0.846645
#NORMAL DISTRIBUTIONS
#a)
pnorm(10000,mean=25000,sd=10000)
## [1] 0.0668072
#b)
pnorm(30000,mean=25000, sd=10000)-pnorm(20000,mean=25000,sd=10000)
## [1] 0.3829249
(pnorm(30000,mean=25000, sd=10000)-pnorm(20000,mean=25000,sd=10000))*100
## [1] 38.29249
#POISSON DISTRIBUTIONS
#poisson no.1
#a)30-page book will have no typos
4*3
## [1] 12
dpois(0,lambda=4*3)
## [1] 0.000006144212
#b) 300-page book will have more than 5 typos
1-ppois(5,12)
## [1] 0.979659
#c)book of 157 pages has no typos
dpois(0,(157/100)*4)
## [1] 0.001873401
#d)simulations
rpois(30,4)
##  [1]  3  2  3  5  4  3  4  1  5  3  5  4  3  3  4  7  3  5  8  5  5  2  6  4  8
## [26]  3  3 12  5  6
#poisson no.2
#a) more than 7 accidents in May
1-ppois(7,4)
## [1] 0.05113362
#b) no more than 3 accidents in May and June
ppois(3,8)
## [1] 0.04238011
#poisson no.3
#a)zero calls during one minute period
dpois(0,2)
## [1] 0.1353353
#b)less that one call in 5 minutes
ppois(4,2)
## [1] 0.947347
#c)less than 6 calls in one hour
ppois(5,(2*60))
## [1] 0.00000000000000000000000000000000000000000001658476
#BETA PROBABILITY DISTRIBUTION
#a)mean and variance
#mean;
mean_beta<-4/(4+2);mean_beta
## [1] 0.6666667
#variance;
variance_beta<-(4*2)/((4+2)^2*(4+2+1));variance_beta
## [1] 0.03174603
#b)probability that at least 80% of the computers are sold
1 - pbeta(0.8,4,2)
## [1] 0.26272