Created
June 4, 2013 22:08
-
-
Save grantbrown/5710043 to your computer and use it in GitHub Desktop.
Animated illustration of how degrees of freedom affect the shape of the student's-t distribution.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# T Distribution Illustration | |
TimeDelay = 0.5 | |
plotT = function(df, add = FALSE) | |
{ | |
f = function(x) | |
{ | |
return(dt(x, df)) | |
} | |
curve(f, xlim = c(-6,6), ylim = c(0, 0.5), add = add, main = "T Distribution vs. Standard Normal",ylab = "Density") | |
curve(dnorm, add=T, lty = 2, col = "red") | |
legend(x = -6,y=0.5,legend = c("Normal"), lty = 2, col = "red") | |
text(x = 2.5, y = 0.4, labels = paste("Degrees of Freedom: ", df, sep = "")) | |
} | |
for (i in 1:100) | |
{ | |
plotT(i) | |
Sys.sleep(TimeDelay) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment