Reply
Wed 20 May, 2015 12:26 pm
how can I do this in R? Use these "pnorm" and "pbinom" to plot the cumulative distribution function of the standard normal distribution (of parameters 0,1) and of binomial distributions of parameters n=20, 50, 100 and p=0.1, 0.4. Note that the first curve should be smooth. The other ones should be step functions. Produce two or three plots illustrating the approximation of the cumulative distribution function of a centered reduced binomial variable by the normal cumulative distribution function.
This is what I have so far but doesn't seem to work
x=seq(-4,4,length=200)
y=1/sqrt(2*pi)exp(-x^2/2)
plot(x,y,type="l",lwd=2,col="red")
par(new=TRUE)
k <- seq(-4, 4, by = .5)
lot(k,pbinom(k, 100, .1, log = TRUE), type = "s", ylab = "log density", main='pbinom(,log=TRUE)')
plot7
par(new=TRUE)
plot(k,pbinom(k, 100, .4, log = TRUE), type = "s", ylab = "log density", main='pbinom(,log=TRUE)')
par(new=TRUE)
plot(k,pbinom(k, 20, .4, log = TRUE), type = "s", ylab = "log density", main='pbinom(,log=TRUE)')