Skip to content

Instantly share code, notes, and snippets.

@reyjrar
Created May 17, 2011 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reyjrar/977455 to your computer and use it in GitHub Desktop.
Save reyjrar/977455 to your computer and use it in GitHub Desktop.
Graph a Chi-Squared Distribution with 5 Degrees of Freedom
# Generic Chi-Squared Graph at 5 D of F.
x <- seq(0, 20, length=100)
hx <- dchisq(x, 5)
plot(x, hx, type="l", col="red", xlab="test statistics",
ylab="Density", main="Chi-Squared Distribution")
segments( x0=9.26, y0=0, x1=9.236, y1=max(hx), lty=2 )
text( 12, 0.12, "cv=9.236" )
legend( "topright", inset=0.05, c("df = 5"), lty=c(1), col=c("red") )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment