Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
24 lines (18 sloc) 921 Bytes
library(ggplot2)
ladies = c(8.07,6.03,5.49,6.48,5.01,7.23,7.8,4.9,6.2,5.8,4.8,6.5,5.1,5.2,4.5,4.9,5.5,5.3,5.9,4.8)
ladiesdf=data.frame(ladies)
plot1=ggplot(ladiesdf)+geom_dotplot(aes(x=ladies),method="histodot",color="dodgerblue3",fill="dodgerblue3",stackratio = 1.05,dotsize=0.5,binwidth = 0.5)
plot1=plot1+xlab("Score")+ylab("Density")
#+theme(axis.text.y = element_blank())
theta = sd(ladies)
zero = mean(ladies) - theta
expx = seq(zero,zero+5*theta,0.1)
expfit = exp((zero-expx)/theta)*theta
efdf = data.frame(expx,expfit)
plot2=plot1+geom_line(data=efdf,aes(x=expx,y=expfit),color="dodgerblue4",size=2)
dates=seq(0,50)
dexp=numeric(51)
dexp[1]=4.8
for (i in 2:51) {dexp[i]=exp(4.8-dexp[i-1])*(dexp[i-1]+1) + (1-exp(4.8-dexp[i-1]))*(dexp[i-1])}
datedf=data.frame(dates,dexp)
plot3=ggplot(datedf) + geom_point(aes(x=dates,y=dexp,color=dexp))+xlab("Dates Left")+ylab("Expectation")+theme(legend.position = "none")
You can’t perform that action at this time.