We now model our Poisson probability of breaking down within each of the first 10 years. Our number of interest, within 8 years, is highlighted.

library(ggplot2)
library(gridExtra)
set.seed(2424)
p<-runif(5, min = 0, max = 1)
r<-runif(5, min = 0, max = 1)
s<-runif(5, min = 0, max = 1)
t<-runif(5, min = 0, max = 1)
q<-c(1:5)
our.frame<-data.frame(cbind(p,q,r,s,t))
our.frame
plot.a<-ggplot(data=our.frame, aes(x=q,y=p)) +
geom_point(shape = 21, size = 5,stroke=1.5) + scale_color_manual(values=c("#022082", "#a3204e"))+ theme(panel.background = element_rect(fill = '#8b9ca5'))+geom_hline(yintercept=min(p))+ylim(0,1)
plot.b<-ggplot(data=our.frame, aes(x=q,y=r)) +
geom_point(shape = 21, size = 5,stroke=1.5) + scale_color_manual(values=c("#022082", "#a3204e"))+ theme(panel.background = element_rect(fill = '#8b9ca5'))+geom_hline(yintercept=min(r))+ylim(0,1)
plot.c<-ggplot(data=our.frame, aes(x=q,y=s)) +
geom_point(shape = 21, size = 5,stroke=1.5) + scale_color_manual(values=c("#022082", "#a3204e"))+ theme(panel.background = element_rect(fill = '#8b9ca5'))+geom_hline(yintercept=min(s))+ylim(0,1)
plot.d<-ggplot(data=our.frame, aes(x=q,y=t)) +
geom_point(shape = 21, size = 5,stroke=1.5) + scale_color_manual(values=c("#022082", "#a3204e"))+ theme(panel.background = element_rect(fill = '#8b9ca5'))+geom_hline(yintercept=min(t))+ylim(0,1)
grid.arrange(plot.a, plot.b,plot.c, plot.d, nrow = 2)
poisson.data <- data.frame(probability=double(),
n=double(),
tag=logical(),
stringsAsFactors=FALSE)
poisson.data[1,1]<- (exp(-.8)*.8^0)/factorial(0)
poisson.data[1,2]<- 0
poisson.data[1,3]<- TRUE
for(i in 1:10){
poisson.data[i+1,1] <-(exp(-.8)*.8^i)/factorial(i)
poisson.data[i+1,2] <-i
poisson.data[i+1,3] <-FALSE
}
poisson.data
plot.e<-ggplot(data=poisson.data, aes(x=poisson.data[,2],y=poisson.data[,1]),color=poisson.data[,3]) +
geom_bar(stat='identity',aes(fill=poisson.data[,3])) + scale_fill_manual(values=c("#022082", "#a3204e"))+ theme(panel.background = element_rect(fill = '#8b9ca5'))+ylim(0,1)+theme(legend.position="none")+labs(x="number of failures in 8 years",y="probability")
plot.e
for (i in 1:10) {
poisson.data[i,1]<-((exp(-(.1*i))*(.1*i)^0))/factorial(0)
poisson.data[i,2]<-i}
poisson.data[1,3]<-FALSE
poisson.data[8,3]<-TRUE
poisson.data
plot.e<-ggplot(data=poisson.data, aes(x=poisson.data[,2],y=poisson.data[,1]),color=poisson.data[,3]) +
geom_bar(stat='identity',aes(fill=poisson.data[,3])) + scale_fill_manual(values=c("#022082", "#a3204e"))+ theme(panel.background = element_rect(fill = '#8b9ca5'))+ylim(0,1)+theme(legend.position="none")+labs(x="no failures in N years",y="probability")
plot.e