Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I collected data for a discrete probability distribution and I have the pairs (value, probability).

Value    Probability
 90      0,0033
125      0.0204
180      0.0847
250      0.2516
355      0.4653
500      0.175
710      0.0015

I have been asked to compute a gaussian fit over that data but I am having troubles. Is it possible (and does it make sense) to fit a gaussian distribution over it?

I tried to build the corresponding gaussian distribution by computing mean (334) and standard deviation (100) of my data but, of course, it does not work.

Gaussian density function values are related to continuous values while the probability I have are continuous.

I guess that I have too few discrete values to compute the gaussian distribution, but I am not really into statistics so I am not sure and I'd like to double check with you that I'm not missing something.

share|improve this question
up vote 6 down vote accepted

A "Gaussian fit" to a discrete probability distribution makes little or no sense in statistical applications, but mathematically almost a perfect fit can be made to these ordered pairs. Just find values $m$ and $s$ for which the cumulative Gaussian $$\Phi(x;m,s)=\frac{1}{\sqrt{2 \pi s^2}}\int_{-\infty}^x \exp(-(t-m)^2/s^2) dt$$ closely agrees with the data.

To illustrate the computation, here is an example of least-squares fitting (in R). Because the probabilities do not sum exactly to $1$, it standardizes them to sum to unity.

# The data
x <- c(90, 125, 180, 250, 355, 500, 710)
p <- c(0.0033, 0.0204, 0.0847, 0.2516, 0.4653, 0.1750, 0.0015)

# Standardize the cumulative probabilities
prob <- cumsum(p); prob <- prob / prob[7]

# Compute sum of squared residuals to a fit
f <- function(q) {
  res <- pnorm(x, q[1], q[2]) - prob
  sum(res * res)

# Find the least squares fit
coeff <-(fit <- nlm(f, c(334, 100)))$estimate

# Plot the fit
plot(x, prob)
curve(pnorm(x, coeff[1], coeff[2]), add=TRUE)


The optimal values are $m \approx 279.5$, $s \approx 80.5$.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.