dchisq and dnorm Plots

I tried this for plotting out some chi-square distributions with various df and it seemed to work out:

s<-seq(0,25,.01)
plot(s,dchisq(s,2),type="l",lwd=2,col="dodgerblue4")
lines(s,dchisq(s,5),type="l",lwd=2,col="green1")
lines(s,dchisq(s,10),type="l",lwd=2,col="orange1")

This should look something like this:

Here’s something similar for a normal distribution (notice that I use slightly different code for plotting the curves):

n=15
curve(dnorm(x,mean=0,sd=1/sqrt(n)),-5,5,xlab="x",
ylab="Density",lwd=4,col="dodgerblue4")
n=5
curve(dnorm(x,mean=0,sd=1/sqrt(n)),-5,5,xlab="x",
ylab="Density",lwd=4,col="green1",add=T)
n=1
curve(dnorm(x,mean=0,sd=1/sqrt(n)),-5,5,xlab="x",
ylab="Density",lwd=4,col="orange1",add=T)

This should end up looking like this:

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>