在 Excel 中 =T.INV(0.9,5) 返回值“1.475884”。
现在我在 C# 中使用 WorksheetFunction TINV(0.9,5) 的函数。但这给了我结果 0.1321751752。
因此,在 C# 中,TINV 结果的值与 excel 的值相差太多。
Microsoft.Office.Interop.Excel.Application xl = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.WorksheetFunction wsf = xl.WorksheetFunction;
double result = wsf.TInv(0.9, 5);
使用另一个 NuGet DLL 也发现了与以前的 DLL 相同的值:
var chart = new System.Web.UI.DataVisualization.Charting.Chart();
double resultTest = chart.DataManipulator.Statistics.TDistribution(.9, 5, true);
因此,我需要与在 Excel Worksheet **T.Inv**
函数中找到的值相同。
如何在 C# 中获得相同的 T.INV 值。
有人能帮我得到同样的结果吗?
最佳答案
此代码返回学生 t 分布的左尾和双尾逆
static void Main(string[] args)
{
double value = 0.9;
int degree = 5;
var chart = new System.Web.UI.DataVisualization.Charting.Chart();
double resultTest = chart.DataManipulator.Statistics.InverseTDistribution(value, degree);
Console.WriteLine(resultTest);
//left-tailed
double result = alglib.invstudenttdistribution(degree, value);
Console.WriteLine(result);
}
附言我使用了此处可用的 invstudenttdistribution 函数 alglib.net
关于c# - Excel公式T.INV计算错误使用C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53932658/