Hi,

I'm a programmer who's in the process of converting a tool built in Excel into a C# program. I've managed to port everything except for the NORMDIST() function, which is scaring the hell out of me.

I need to work out the cumulative normal distribution given x, the mean and the standard deviation. I posed this question in one of the C# question areas and got what I thought was an answer to my question:

http://www.experts-exchange.com/Programming/Programming_Languages/C_Sharp/Q_20936306.html
But it turned out not to work, for instance:

x = 2.01490302054226

mean = 3.24088418968677

std dev = 0.427899387582919

Using NORMDIST(x,mean,stddev,TRU

E) Excel gives me: 0.00208435088016279

The C# function gives me: 556735840.808829

Sometimes the C# function is spot on, sometimes it's way off like above.

I don't need anyone to write the C# function for me (although it would be nice if you did), I just need it explaining in english how I go about calculating it using basic maths.

If anyone can help, or point me in the right direction?

Cheers,

LittleC
-pow((x-u),2) / (2*pow(deviation,2))

the remainder of your formula looks fine.