###Normal
#mean of ACT scores (mean), standard deviation of ACT scores (sd)
mean<-20.8
sd<-5.8
curve(dnorm(x,mean=mean,sd=sd),from = 5, to = 36,main="ACT Scores", xlab = "ACT Score",ylab = "Probability Density")

###Binomial
#number of patients (n), probability the drug cures the patient (p)
n<-50
p<-0.35
# Generate success counts (0 to n) and their corresponding probabilities
x <- 0:n
probabilities <- dbinom(x, size = n, prob = p)
barplot(probabilities,names.arg=x, xlab="Number of patients cured",ylab="Probability",main=paste("Binomial Distribution (n=",n,", p=",p,")"))

###Poisson
#average number of clicks on a digital ad per day (lambda)
lambda<-5.3
x_values<-0:20
poissoncurve<-dpois(x_values,lambda = lambda)
barplot(poissoncurve,names.arg=x_values,main="Number of Clicks on a Digital Ad", xlab="Number of Clicks per Day", ylab="Probability")

Hospital neurosurgeon team performs n procedures. x procedures resulted in death. National rate of death in these cases is pi. The null hypothesis is that the hospital’s death rate (x/n) is the same as the national average (pi).

n<-100
x<-12
pi<-0.08

#probability of observing 12 or more deaths:

#Binomial
p_binom<-pbinom(x-1,size=n,prob=pi,lower.tail = FALSE)
p_binom
## [1] 0.1028452
#Poisson
lambda<-n*pi
p_poisson<-ppois(x-1,lambda = lambda,lower.tail = FALSE)
p_poisson
## [1] 0.111924
significant<-0.05
p_binom>significant
## [1] TRUE
p_poisson>significant
## [1] TRUE

The p-values using both types of distributions are greater than 5%, which means that we fail to reject the null hypothesis at a 95% confidence level. In other words, there is not enough evidence to suggest that the hospital’s death rate is unusually more extreme (e.g., unusually high) than the national proportion.