## "Statistical foundations of machine learning" software
## R package gbcode
## Author: G. Bontempi
# cumdis_2.R
# Script: visualizes the unbiasedness of the empirical distribution function
par(ask=TRUE)
rm(list=ls())
N<-100
R<-100
I<-seq(-5,5,by=.1)
emp<-NULL
for (i in 1:R){
DN<-rnorm(N)
F<-ecdf(DN)
emp<-rbind(emp,F(I))
m.emp<-apply(emp,2,mean) # average of the empirical function
plot(I,m.emp,main=paste("Average of ",i," empirical distributions made with ", N, " samples"))
lines(I,pnorm(I),pch=15) # distribution function
legend(-4,1,legend=c("Empirical","Gaussian"),lty=c(3,1))
}
#m.emp<-apply(emp,2,mean) # average of the empirical function
#plot(I,m.emp)
#lines(I,pnorm(I),pch=15) # distribution function
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.