我正在运行一些蒙特卡罗模拟并广泛使用 Excel 函数NORM.INV 使用 Office Interrop.此函数采用三个参数(概率、平均值、标准差)并返回累积分布的倒数.
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.
我想将我的代码移动到网络应用程序中,但这需要在服务器上安装 Excel.有谁知道与 NORM.INV 具有等效功能的 C# 统计库吗?
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?
Meta.Numerics 正是您要寻找的.这是使用该库执行此操作的代码:
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);
如果您这样做是为了生成法线偏差,GetRandomValue 函数会更快.
If you are doing this in order to generate normal deviates, the GetRandomValue function is even faster.
这篇关于是否有执行 Excel NORMINV 函数的 C# 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!