In: Statistics and Probability
In r-studio, given X=rpois(200,2). Generate a poisson probability histogram with lambda=2 and a relative frequency histogram of the sample on the same graph-------- //answer this only if youre familiar with R studio and know how to using it. not handwritten//
Here we use R-studio
#The R-code is
X=rpois(200,2)
Prob=dpois(0:8,2) #Probaility for Poisson
F=200*Prob # Expected Frequency
Y=rep(0:8,F)
c1=rgb(173,216,230,max = 255, alpha = 80, names = "lt.blue")#colour
c2=rgb(255,192,203, max = 255, alpha = 80, names = "lt.pink")#colour
hist(X,col=c1,breaks=7,freq=FALSE)
hist(Y,col=c2,add=T,breaks=7,freq=FALSE)
legend("topright",legend=c("Random numbers from Poisson 2","Poisson distribution with lambda=2"),fill=c(c1,c2))
#The output of the code is
>X=rpois(200,2)
>Prob=dpois(0:8,2) #Probaility for Poisson
>F=200*Prob # Expected Frequency
>Y=rep(0:8,F)
>c1=rgb(173,216,230,max = 255, alpha = 80, names = "lt.blue")#colour
>c2=rgb(255,192,203, max = 255, alpha = 80, names = "lt.pink")#colour
>hist(X,col=c1,breaks=7,freq=FALSE)
>hist(Y,col=c2,add=T,breaks=7,freq=FALSE)
>legend("topright",legend=c("Random numbers from Poisson 2","Poisson distribution with lambda=2"),fill=c(c1,c2))
#Here freq=FALSE for relative frequency