# Calculate the likelihood from the density function with known mean and sd

In this link the likelihood of IQ has been calculated by using dnorm function in R. Here they used "%" sign but based on the range of sample.range variable the sum of iq.dist can be greater than one. For example:

> sum(dnorm(seq(-1,1,0.001), mean =0, sd =1))
> 682.9314


Is it correct to use % for the result of likelihood here?

This function may not generate the right result all the time:

  pp(sum(iq.df$$Density[iq.df$$IQ <= 90]))


What is the correct method to calculate the likelihood in such scenarios?

## 1 Answer

If you want to calculate the likelihood that IQ falls within the range $$(a,b)$$ you have to integrate the probability density function over that region. You can approximate the integral in R using the following sum:

sum(0.001 * dnorm(seq(-1,1,0.001), mean =0, sd =1))


which is your code, with an additional factor of "0.001."

The article is using a step size of 1 instead of 0.001. Of course multiplying by 1 has no effect, so the article writer did not bother to include it explicitly in their code!

If you make the step size smaller, your integral is more accurate, so total probability will be closer to 1 or 100%. But of course, IQ values are always whole numbers in real life! Increments of 0.001 are a mathematical fiction that arise from pretending that the data are perfectly normal. So it's questionable how much you really gain by insisting on this level of mathematical accuracy.

Alternately you can just use the cumulative distribution function (pnorm or qnorm), where the integral has already been done for you. But personally speaking, I view the density function as a more fundamental concept. In most cases I think in terms of the density function, and treat the cumulative distribution as a useful shortcut to avoid calculating integrals.