I have a fifteen point grading system [1...15], where the expectations:
- 5% of the population is less than 5
- 10% of the population is greater than 10
- remaining population is centered around 8
It is easy enough to plot a histogram of my frequency but I want to plot a couple of curves over the top of this histogram
- a curve to represent an expected normal distribution using the full range (1-15) with a mean of 8 and a sd of 2
- a second curve showing an expected normal distribution using the effective/practical range 5-10 with a mean of 8 and a sd of 1
I haven't used R in years and am struggling a bit. Here is where I am at:
grades <-c(6,6,5,5,8,8,8,8,9,9,9,9,1,5,5,5,5,5,5,5,13,15)
xbar <- mean(g)
sdev <- sd(g)
plotCurve <- function(discreteRangeMin, discreteRangeMax, targetMean, targetDev, color) {
granularityFactor <- 4
xfit <- seq(discreteRangeMin, discreteRangeMax, length=discreteRangeMax * granularityFactor)
yfit <- dnorm(xfit, mean = targetMean, sd = targetDev)
plot(xfit, yfit, type='l', axes=F, xlab='', ylab='', col=color)
return (yfit)
}
plotHist <- function(g, title) {
zeroThrough15 <- seq(0, 15, length = 16)
hist(g, breaks=zeroThrough15, freq=T, main=title )
axis(side=1, at=zeroThrough15, labels=zeroThrough15)
}
# main histogram
title <- paste('Distribution [mean=', round(xbar, 2) , '', ', sd=', round(sdev, 2), ']', sep='')
plotHist(grades, title)
# add the expected 'full' distribution over the entire range
par(new=T)
yfit <- plotCurve(1, 15, targetMean=8, targetDev=2, 'green')
axis(side=4, at = pretty(range(yfit)))
# add the expected 'practical' distribution over typical range
par(new=T)
yfit2 <- plotCurve(5, 10, targetMean=8, targetDev=0.5, 'red')
Issues
- The second curve isn't what I was expecting. I only want it to extend over the range 6-13
- A third curve that carves out the expected distribution with 5% < 5, the 10% > 10, and ~normal distribution between 5-10 with 85% percent
- lastly how do I get the labels under the histogram to line up with the buckets better?