# define the random variable >> =imperfection
# identify the distributuion of the random variable >> =poisson(lamda) normal(meanandstd) binom(nandP)
# identify parameter  values>> =lamda=0.2 imperfection/min
# Write the probablity statement>> = P(x=1) in 3 mins
# Write  the R command
# Write the answer to three decial places

#pnorm(110,100,15)#input quatity output probablity
#1-pnorm(90,100,15) #for x>90 and top-bottom for 90<x<110
#qnorm(0.1,65,1.5) # when % given

#pbinom(5,10,0.05)#when x=5 catch 5 fish
#pbinom(4,10,0.05)#when x<5
#1-pbinom(1,10,0.05) #when at least 2

#dbinom(5,10,0.05) #binomial stuffs
#pbinom(4,10,0.05)
#1-pbinom(1,10,0.05)

#dpois(1,0.2*(3)) # one perfection in 3 minutes only one point that why we use d instead of q
#1-ppois(1,0.2*5) # at least 2 perfection in 5 mins
#ppois(1,0.2*15) # at most one imperfection in 0.25 hours

#The probablity of between 2 and 3 imperfections(inclusive) in 1 minute
#ppois(3,0.2*1)-ppois(2,0.2*1) #NOT A RIGHT WAY bc not include 2 but we NEED 2
#ppois(3,0.2*1)-ppois(1,0.2*1) #THIS IS RIGHT bc it also includes 2

#Practice#

# find 3 <x< 9 testers
#pbinom(8,20,0.3)-pbinom(3,20,0.3) #answer is probablity that we got 
#pnorm(1,0,1)-pnorm(-1,0,1) #one standard deviation of its mean
#pnorm(2,0,1)-pnorm(-2,0,1) #two standard deviation of its mean

#5% alcohol, 10% no seatbelt, ans they are also independent
#dbinom(3,5,0.05*0.1)
# mean=350, SD=50,pick 5 cadets.. no more than 3 have PFT less than 375
#pbinom(3,5,pnorm(375,350,50)) #input pnorm into it to represent probablity 


# gas car with mean 35.5mpg SD 4.5 mpg 
# what percent for 40mpg or  more?
#1-pnorm(40,35.5,4.5) #input quantity to find probablity
# get 95% what mpg is that?
#qnorm(0.95,35.5,4.5) #input probablity to find quantity

#What GPA required top 10, mean 2.9, SD=0.35
#qnorm(0.9,2.9,0.35)

#Use possion when there is a rate 
# 4calls per mins, x<- number of calls/ 30 mins
# find P(x=0)
#dpois(0,4*1/2) #input quantity x output probablity
# at least 4 calls in 1 min,given 2 calls in 1 min
#1-ppois(3,4) #this one for at least 4 calls: 3 and 4
#1-ppois(2,4) #this one for 2 plus>> 3,4,..
#SO OVER ALL..
#(1-ppois(3,4))/(1-ppois(2,4))

# radio decay at rate 3/sec
#prob that less than 5 will emit
#ppois(4,3)
#Prob that more than 2 will emit
#1-ppois(2,3)
#Prob that between 3 and 4 will emit
#ppois(4,3)-ppois(2,3)

#27 diver/day arrested 
# prob that less than 5 arrested in 6 hrs
#ppois(4,27/4)
# prob that more than 10 arrested in 8 hrs
#1-ppois(10,27*8/24)

#Varience(x)= sigma^2= sum of (x-mu)^2*p(x); sigma=SD
# = E(x^2)-(E(x))^2; E(x)= sum of x*p(x)
#binom chose(n,k)P^k(1-O)^n-k
#pois=lam^x*e^-lam/x!