1

I am a computer programmer working on a project that requires me to transform an image into the approximate shape of a bell curve (normal distribution curve). What I need is a math formula for a simple bell curve that I can pass in the X coordinate and have the Y coordinate be returned. I have looked around the internet for answers, but the formulas I have found have characters that are unknown to me, a non-mathematician. If you can help, I would appreciate it!

  • Functions of the form $y\left(x\right)=\exp\left(-\frac{\left(x-a\right)^2}{b}\right)$ give you Gaussians centred at $x=a$ with 'flatness' given by the $b$ parameter. – WJG Mar 05 '17 at 00:17
  • https://www.wolframalpha.com/input/?i=y%3Dexp(-(x-1)%5E2%2F2), for example ($a=1$, $b=2$). :) – WJG Mar 05 '17 at 00:19
  • @WJG - Ok, can you help me further...what do I plugin for the "a" parameter? And what does "exp" mean? Sorry, I have forgotten a lot since math class back in 1984! – Joe Gayetty Mar 05 '17 at 00:23
  • @WJG - Sorry my last comment got passed by your second one...that second one looks like something I can understand! Thanks. I will give it a closer look. – Joe Gayetty Mar 05 '17 at 00:25
  • Sorry...I am still stumped at "exp" and/or "e" means. – Joe Gayetty Mar 05 '17 at 00:26
  • No problem, $\exp\left(x\right)$ (usually written $e^x$) is the exponential function, which is a lovely curve that decays to zero as $x\to-\infty$ and grows rapidly as $x\to\infty$. Fortunately for you most programming languages should have an exponential function built in for you to use. – WJG Mar 05 '17 at 00:31
  • Thanks @WJG for the information and the quick responses! I actually pounded out a quick formula in C# based on your help... private double CalcY2(double X) { double Y = 0; Y = 1 / (Math.Sqrt(Math.Exp(Math.Pow((X-1),2)))); return Y; } – Joe Gayetty Mar 05 '17 at 00:42

1 Answers1

1

A normal distribution curve depends on two parameters: the mean (written $\mu$) and the variance (written $\sigma^2$). Wikipedia's page on normal distribution gives you the general formula where you can adapt these parameters. The first parameter $\mu$, the mean, indicates the center of symmetry of the curve. Whereas $\sigma^2$, the variance, describes how flat or spread the curve is. If you want to ignore as many parameters as possible, I suggest you use the following.

Given a number $x$, the returned $y$ is: \begin{equation} y=f(x)=e^{-x^2} \end{equation} In other words, given $x$, take its square $x^2$, then take the exponential of $-x^2$.

If you want more flexibility in your curve, use the general formula of Wikipedia's page where you replace $\mu$ and $\sigma^2$ by whatever parameters you like.