# Q1

#This can be solved using Binomial distribution 


?pbinom 
## starting httpd help server ... done
pbinom(q= 12,
       size = 20, 
       prob = .5,
       lower.tail = TRUE    #probabilities are P[X≤x]  = 12
)  - 
  pbinom(q    = 8, 
         size = 20, 
         prob = .5,
         lower.tail = TRUE    #probabilities are P[X≤x]  = 12
  ) 
## [1] 0.6166897
# Q2

#This can be solved using Binomial dsitribution 

plot(x    = 0:13,                                 # x variable
     y   = dbinom(x     = 0:13,                   # y variable 
                  size = 13, 
                  prob = .2
     ), 
     main = 'Binomial Distribution (n=13, p=0.2)', 
     ylab = 'Probability',                         
     xlab = '# Successes',                         
     type = 'h',                                   
     lwd  = 6                                      
)

dbinom(x = 4:5, size = 13, prob = .2)
## [1] 0.15354508 0.06909529
sum(dbinom(x = 4:5, size = 13, prob = .2))
## [1] 0.2226404
round(x = sum(dbinom(x    = 4:5, size = 13, prob = .2)),digits = 4)
## [1] 0.2226
# Q3

#This can be solved using Poisson distribution

sum(dpois(x      = 0:3,lambda = 4.2))   
## [1] 0.3954034
# Q4

#This can be solved using Hypergeomtric distribution


phyper(q = 1,m = 6,n = 17-6, k = 3,lower.tail = T)
## [1] 0.7279412
# Q5

#This can be solved using Hypergeomtric distribution

sum(dhyper(x = 2:6,m = 6,n = 19,k = 6))
## [1] 0.4528515
# Q6

pnorm(q= 1460,mean = 800,sd = 300) -  pnorm(q= 1040,mean = 800,sd= 300)
## [1] 0.197952
# Q9

#This can be solved using Normal Distribution

Y <-qnorm(p= .91,mean = 75.8,sd   = 8.1)

round(x= Y,digits = 0)
## [1] 87
# Q10

n    <- 155
pi   <- .61

MEAN <- n * pi
SD   <- sqrt(pi * (1-pi) * n )

#X=96, pi=.61, n=155

dnorm(x    = 96,mean = .61 * 155, sd= sqrt(.61 * .39 * 155 )
)
## [1] 0.06385071
pnorm(q = 96.5, mean = .61*155, sd = sqrt(.61 * .39 * 155) ) -pnorm(q = 95.5, mean = .61*155, sd = sqrt(.61 * .39 * 155) )
## [1] 0.06378274
dbinom( x = 96,size = 155,prob = .61
)
## [1] 0.06402352
#n, np and n(1-p) ar larger than 10

n  <- 155
p  <- .61
n * p> 10
## [1] TRUE
n * (1-p)   > 10
## [1] TRUE