# Thread: intersection point between gaussians

1. ## 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?

2. 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.

3. 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
$
y=\frac{1}{(2\pi sigma1^{2})^{1/2}}e^{-\frac{1}{2sigma1^{2}}*(x-mu1)^{2}}
$

intersection point between two gaussians:
$\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:
$ln(\frac{1}{(2\pi sigma1^{2})^{1/2}}-\frac{1}{2sigma1^{2}}*(x-mu1)^{2}
$

=
$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:
$ln(\frac{1}{(2\pi sigma1^{2})^{1/2}})-ln(\frac{1}{(2\pi sigma2^{2})^{1/2}})$
$
-\frac{1}{2sigma1^{2}}*(x-mu1)^{2}+\frac{1}{2sigma2^{2}}*(x-mu2)^{2}=0
$

$
K= ln(\frac{1}{(2\pi sigma1^{2})^{1/2}})-ln(\frac{1}{(2\pi sigma2^{2})^{1/2}})
$

$K-\frac{1}{2sigma1^{2}}(x^{2}-2mu1*x+mu1^{2})+\frac{1}{2sigma2^{2}}(x^{2}-2mu2+mu2^{2})=0
$

$(\frac{1}{2sigma1^{2}}+\frac{1}{2sigma2^{2}})x^{2} +(\frac{1}{2sigma1^{2}}2mu1-\frac{1}{2sigma2^{2}}2mu2)x
$

$+K-\frac{mu1^{2}}{2sigma1^{2}}+\frac{mu2^{2}}{2sigma2 ^{2}}=0
$

4. 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

5. 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
$\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}}$

$\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}$

$\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)$

$\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.

6. 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.

7. 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.
$
-\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
$
-\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
$
\mu_{1}=-955 \textrm{ }\sigma_{1}^{2}=396
$

$
\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.

8. Hmm the intersection data was wrong, so here is the correct approximated solution.
for two Gaussians with
$
\mu_{1}=-955\textrm{ }\sigma_{1}^{2}=396
$

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

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

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