問題描述
我正在運行一些蒙特卡羅模擬并廣泛使用 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模板網!