In: Statistics and Probability
Provide plots of the χ2(r) distributions (pdf) for values of r = 1,2,5,10,20.
par(mfrow=c(3,2))
x <- rchisq(100, 1)
hist(x, prob=TRUE)
curve( dchisq(x, df=1), col='green', add=TRUE)
x <- rchisq(100, 2)
hist(x, prob=TRUE)
curve( dchisq(x, df=2), col='red', add=TRUE )
x <- rchisq(100, 5)
hist(x, prob=TRUE)
curve( dchisq(x, df=5), col='orange', add=TRUE )
x <- rchisq(100, 10)
hist(x, prob=TRUE)
curve( dchisq(x, df=10), col='black', add=TRUE )
x <- rchisq(100, 20)
hist(x, prob=TRUE)
curve( dchisq(x, df=20), col='blue', add=TRUE )
For single plot
x <- rchisq(100, 1)
hist(x, prob=TRUE ,xlim=c(0,10))
curve( dchisq(x, df=1), col='green', add=TRUE)
x <- rchisq(100, 2)
curve( dchisq(x, df=2), col='red', add=TRUE )
x <- rchisq(100, 5)
curve( dchisq(x, df=5), col='orange', add=TRUE )
x <- rchisq(100, 10)
curve( dchisq(x, df=10), col='black', add=TRUE )
x <- rchisq(100, 20)
curve( dchisq(x, df=20), col='blue', add=TRUE )