library(agricolae)
# It prepares a data set, in which evalue the function
# Modern theory of probabilities, Parzen 1960
x<-seq(0,12,length=100)
y<-rep(0,length(x))
for(i in 1:length(x)){
if (x[i] <= 0) y[i]<-0
if ((x[i]>0) & (x[i] < 1) ) y[i]<-x[i]/4
if ((x[i]>=1) & (x[i] <= 2) ) y[i]<-1/3
if ((x[i]>2) & (x[i] <= 3) ) y[i]<-x[i]/6
if ((x[i]>3) & (x[i] <= 4) ) y[i]<-1/2
if ((x[i]>4) & (x[i] <= 8) ) y[i]<-x[i]/8
if (x[i] >8) y[i]<-1
}
disc<-c(0,1,2,3,4,8,12)
# execute function.
#startgraph
plot.disc(x,y,disc,type="l",lty=1,col="blue",lwd=2)
#endgraph
Run the code above in your browser using DataLab