help(hist) help(rgamma) x<-rgamma(100,10) hist(x) hist(x,prob=T) y<-seq(from=0,to=30,length=1000) lines(y,dgamma(y,shape=10)) hist(x,prob=T,breaks="Scott") lines(y,dgamma(y,shape=10)) hist(x,prob=T,breaks="FD") lines(y,dgamma(y,shape=10)) hist(c(x,50),prob=T,breaks="FD") lines(y,dgamma(y,shape=10)) hist(c(x,50),prob=T,breaks="FD",ylim=c(0,0.15)) lines(y,dgamma(y,shape=10)) hist(c(x,50),prob=T,breaks="Scott",ylim=c(0,0.15)) lines(y,dgamma(y,shape=10)) hist(c(x,50),prob=T,breaks="Sturges",ylim=c(0,0.15)) lines(y,dgamma(y,shape=10)) library(MASS) truehist(c(x,50),prob=T,ylim=c(0,0.15)) lines(y,dgamma(y,shape=10)) truehist(c(x,50),prob=T,nbins="FD",ylim=c(0,0.15)) lines(y,dgamma(y,shape=10)) truehist(c(x,50),prob=T,nbins="Scott",ylim=c(0,0.15)) lines(y,dgamma(y,shape=10)) truehist(c(x,50),prob=T,nbins="FD",ylim=c(0,0.15)) lines(y,dgamma(y,shape=10))