Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a C# library that will perform the Excel NORMINV function?

I'm running some Monte Carlo simulations and making extensive use of the Excel function NORM.INV using Office Interrop. This functions takes three arguments (probability, average, standard deviation) and returns the inverse of the cumulative distribution.

I'd like to move my code into a web app, but that will require installing Excel on the server. Does anybody know of a C# statistics library that has an equivalent function to NORM.INV?

like image 888
Portman Avatar asked May 25 '10 03:05

Portman


People also ask

Why is there a slash between AC?

Why is there a slash between A and C in A/C? AC is used as an abbreviation for alternating current and A/C for air conditioning. For most people AC is used for alternating current because it was the first use of this abbreviation and A/C is used for air conditioning to differentiate from alternating current.

Which is correct AC or AC?

Senior Member. A/C unit (air conditioning unit) is a single machine. (e.g. What's that ugly box on your wall? - It's the air conditioning unit.) A/C (air conditioning) is the entire system, or the result it gives.

Why is it called AC?

He combined moisture with ventilation to "condition" and change the air in the factories, controlling the humidity so necessary in textile plants. Willis Carrier adopted the term and incorporated it into the name of his company. Domestic air conditioning soon took off.

What is AC?

What A/C Means. The term “A/C” stands for “air conditioning,” but it's frequently used to describe any type of home cooling equipment, such as a traditional split-system air conditioner or heat pump, mini-split unit, geothermal system, or even a window unit.


2 Answers

Meta.Numerics has exactly what you are looking for. Here is the code to do it using that library:

Distribution n = new NormalDistribution(mean, standardDeviation);
double x = n.InverseLeftProbability(probability);

If you are doing this in order to generate normal deviates, the GetRandomValue function is even faster.

like image 154
David Wright Avatar answered Sep 28 '22 02:09

David Wright


I was also needing a C# implementation of NORMINV, the closest thing I found was a C++ implementation http://www.wilmott.com/messageview.cfm?catid=10&threadid=38771, so I made a quick and dirty translation to C#, the details here http://weblogs.asp.net/esanchez/archive/2010/07/29/a-quick-and-dirty-implementation-of-excel-norminv-function-in-c.aspx. I have made only a few basic tests so be careful if you decide to use it, anyway, hope it helps!

like image 31
Édgar Sánchez Gordón Avatar answered Sep 28 '22 04:09

Édgar Sánchez Gordón