c# - Excel公式T.INV计算错误使用C#

标签 c# excel excel-formula worksheet-function

在 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

Result

关于c# - Excel公式T.INV计算错误使用C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53932658/

相关文章:

excel-formula - 尝试为嵌套公式或堆叠公式找到正确的代码,但无法找到

c# - 正则表达式仅匹配整数

c# - 尝试编译 ASPNetWebStack 获取 35MSSharedLib1024.snk 缺少私钥

excel - 将发票总额复制到相关客户帐户余额

c# - 使用 ASP.Net Core 2.0 使用 NuGet NPOI 进行 Excel 解析

Excel:如果列中的单元格 = X 的文本值,则在另一张纸上显示文本(在同一行,但在不同的列)

c# - 为什么 ICollection 索引在实例化时不起作用?

c# - 小文件导致 OutofMemoryException

excel - 如果字符串是数字,则将字符串转换为 int

Excel 公式查找表中包含值的最右边的列