# intersection point between gaussians

• Aug 11th 2008, 02:34 AM
Susanne
intersection point between gaussians
Hi.
I am doing a project in computer science where I have a need for determing the intersection point between two gaussians defined by their mean and standard variance e.g. g1(mu1,sigma1^2), g2(mu2,sigma2^2).

How do i find their intersection point in the case where the two distributions only have a single intersection point?
• Aug 11th 2008, 05:12 AM
TKHunny
Just set it up and solve it. After introducing logorithms, it is just a quadratic equation. It's a mess, but it's not any trickier than the Quadratic Formula.

There are two complications, both are easily resolved.

1) What to do with the solution you don't want and how to identify it. The desired intersection is the one between the means.

2) If the variance matches, the quadratic solution is no good. You'll have to rely on symmetry.
• Aug 17th 2008, 06:22 AM
Susanne
Just as a sanity check for finding the intersection check i post my calculations for obtaining the quadratic equation.
It have been a while since i have dealt with equations and i would be really glad if someone could confirm my derivation of the quadratic equation.

Gaussian equation
$\displaystyle y=\frac{1}{(2\pi sigma1^{2})^{1/2}}e^{-\frac{1}{2sigma1^{2}}*(x-mu1)^{2}}$

intersection point between two gaussians:
$\displaystyle \frac{1}{(2\pi sigma1^{2})^{\frac{1}{2}}}e^{-\frac{1}{2sigma1^{2}}*(x-mu1)^{2}}=\\ \frac{1}{(2\pi sigma2^{2})^{\frac{1}{2}}}e^{-\frac{1}{2sigma2^{2}}*(x-mu2)^{2}}$

remove the e:
$\displaystyle ln(\frac{1}{(2\pi sigma1^{2})^{1/2}}-\frac{1}{2sigma1^{2}}*(x-mu1)^{2}$
=
$\displaystyle ln(\frac{1}{2\pi sigma2^{2})^{1/2})}-\frac{1}{2sigma2^{2}}*(x-mu2)^{2}$

moving everything to one side of the equality sign:
$\displaystyle ln(\frac{1}{(2\pi sigma1^{2})^{1/2}})-ln(\frac{1}{(2\pi sigma2^{2})^{1/2}})$
$\displaystyle -\frac{1}{2sigma1^{2}}*(x-mu1)^{2}+\frac{1}{2sigma2^{2}}*(x-mu2)^{2}=0$
$\displaystyle K= ln(\frac{1}{(2\pi sigma1^{2})^{1/2}})-ln(\frac{1}{(2\pi sigma2^{2})^{1/2}})$
$\displaystyle K-\frac{1}{2sigma1^{2}}(x^{2}-2mu1*x+mu1^{2})+\frac{1}{2sigma2^{2}}(x^{2}-2mu2+mu2^{2})=0$

$\displaystyle (\frac{1}{2sigma1^{2}}+\frac{1}{2sigma2^{2}})x^{2} +(\frac{1}{2sigma1^{2}}2mu1-\frac{1}{2sigma2^{2}}2mu2)x$
$\displaystyle +K-\frac{mu1^{2}}{2sigma1^{2}}+\frac{mu2^{2}}{2sigma2 ^{2}}=0$
• Aug 17th 2008, 11:44 PM
Susanne
Ok, now i am confused.
Is it possible to solve this equation as i have done by using a quadratic equation or is it not?

I need the intersection point between the two means, and also know that gaussian1=/gaussian2.

Best regards
Susanne
• Aug 18th 2008, 12:16 AM
mr fantastic
Quote:

Originally Posted by Susanne
Ok, now i am confused.
Is it possible to solve this equation as i have done by using a quadratic equation or is it not?

I need the intersection point between the two means, and also know that gaussian1=/gaussian2.

Best regards
Susanne

$\displaystyle \frac{1}{\sqrt{2 \pi} \, \sigma_1} e^{\frac{-(x - \mu_1)^2}{2\sigma_1^2}} = \frac{1}{\sqrt{2 \pi} \, \sigma_2} e^{\frac{-(x - \mu_2)^2}{2\sigma_2^2}}$

$\displaystyle \Rightarrow e^{ \frac{ -(x - \mu_1)^2}{2\sigma_1^2} + \frac{(x - \mu_2)^2}{2\sigma_2^2} } = \frac{\sigma_1}{\sigma_2}$

$\displaystyle \Rightarrow \frac{ -(x - \mu_1)^2}{2\sigma_1^2} + \frac{(x - \mu_2)^2}{2\sigma_2^2} = \ln \left( \frac{\sigma_1}{\sigma_2} \right)$

$\displaystyle \Rightarrow -\sigma_2^2 (x - \mu_1)^2 + \sigma_1^2 (x - \mu_2)^2 = 2 \sigma_2^2 \sigma_1^2 \ln \left( \frac{\sigma_1}{\sigma_2} \right)$

It is simple but tedious to expand the left hand side, re-arrange and solve the quadratic for x. I'd suggest introducing some notation to streamline things. Use the discriminant to set conditions on the mean and variances such that you have the desired number of solutions.
• Aug 19th 2008, 12:44 AM
Susanne
Thanks a lot for the answer mrfantastic. So it is possible to solve this problem using the equations, and i do not have to solve it numerically.
• Sep 7th 2008, 04:23 AM
Susanne
well to completely show how much i sucks at this i would much appreciate a review of the quadratic equation since the results are not correct.
$\displaystyle -\frac{1}{2\sigma_{1}^{2}}(x^{2}-2\mu_{1}x+\mu_{1}^{2})+\frac{1}{2\sigma_{2}^{2}}(x ^{2}-2\mu_{2}x+\mu_{2}^{2})$
more rearranging
$\displaystyle -\frac{1}{2\sigma_{1}^{2}}+\frac{1}{2\sigma_{2}^{2} }x^{2}+\mu_{1}\frac{1}{2\sigma_{1}^{2}}-\mu_{2}\frac{1}{2\sigma_{2}^{2}}x-\frac{1}{2\sigma_{1}^{2}}\mu_{1}^{2}+\frac{1}{2\si gma_{2}^{2}}\mu_{2}^{2}-ln\left(\frac{\sigma_{1}}{\sigma_{2}}\right)=0$
when inserting
$\displaystyle \mu_{1}=-955 \textrm{ }\sigma_{1}^{2}=396$
$\displaystyle \mu_{2}=-1578 \textrm{ }\sigma_{2}^{2}=1117$
I get y values -1878 and -1433 and this confuses me a bit.
I would expect very small numbers denoting the probability and according to my plot it should be around 0.000036.
The intersection point according to the plot should lie between -1530 and -1520.
• Sep 7th 2008, 09:52 AM
Susanne
Hmm the intersection data was wrong, so here is the correct approximated solution.
for two Gaussians with
$\displaystyle \mu_{1}=-955\textrm{ }\sigma_{1}^{2}=396$

$\displaystyle \mu_{2}=-1578\textrm{ }\sigma_{2}^{2}=1117$

the approximated intersection point is at -1190 and the probability being
$\displaystyle 3.0e^{-032}$

But i still haven't been able to poduce the correct answer using the quadratic equation. (Doh)