Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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 have two xy curves, defined numerically on a given (potentially different) range of x coordinates. What I need to do is to compare these two curves with the following strategy:

  1. express each curve as a sum of unknown gaussian functions, to be determined.
  2. compare the two sets of gaussians.
  3. obtain a similarity score ranging from 0% (absolutely no similarity) to 100 % (they are the same).

I am not looking for exceedingly fancy algorithms for these tasks, but any hint and keywords to search for will certainly be welcome.

share|cite|improve this question
Are there some restrictions on the kind of curves you have? I think what you need is known in quantum mechanics as an overcomplete set of coherent states. But in QM, the states are usually complex wave functions. Another way to think about it is in terms of wavelets. – Raskolnikov Sep 28 '11 at 19:09
up vote 2 down vote accepted
  1. Fix the number of Gaussians $n$ you consider. Then, perform an OLS estimation of the difference between the sum of the $n$ Gaussians and your observations: $$ \min_{\alpha, \mu,\sigma}\;\sum_j\sum_{i=1}^n (\alpha_i\cdot\phi_{\mu_i,\sigma_i}(x_j)-y_j)^2. $$
  2. Use a nonlinear optimization algorithm for this, e.g., the scipy package in Python. This gets you two sets of $(\alpha, \mu, \sigma)$, which you can compare.
  3. For comparison, take again the sum of squared differences of the parameters, appropriately weighted, and apply $\exp(-\cdot)$ to map this into $(0, 1]$. However, other similarity mappings might be more appropriate for your application -- you might want to experiment here a bit.

EDIT: There is a whole theory about nonlinear least squares, which might work better than simply trying to optimize the objective function shown above.

share|cite|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.