使用C#的Excel公式T.INV计算错误 [英] Excel Formula T.INV Calculation wrong using C#

查看:52
本文介绍了使用C#的Excel公式T.INV计算错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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 =新的Microsoft.Office.Interop.Excel.Application();Microsoft.Office.Interop.Excel.WorksheetFunction wsf = xl.WorksheetFunction;双重结果= 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工作表 ** T.Inv ** 函数中找到的值相同.

如何在c#中获得相同的T.INV值.

有人可以帮助我获得相同的结果吗?

解决方案

此代码返回学生t分布的左尾和两个尾部倒数

 静态void Main(string [] args){双精度值= 0.9;整数度= 5;var chart = new System.Web.UI.DataVisualization.Charting.Chart();double resultTest = chart.DataManipulator.Statistics.InverseTDistribution(value,degree);Console.WriteLine(resultTest);//左尾双重结果= alglib.invstudenttdistribution(度,值);Console.WriteLine(result);} 

P.S.我使用了此处可用的invstudenttdistribution函数

In Excel =T.INV(0.9,5) returns the value '1.475884'.

Now I am using the function of WorksheetFunction TINV(0.9,5) in C#. But this gives me result 0.1321751752.

So, in C# TINV result has too much different value than 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);

Using another NuGet DLL also found same value as previous DLL:

var chart = new System.Web.UI.DataVisualization.Charting.Chart();
double resultTest = chart.DataManipulator.Statistics.TDistribution(.9, 5, true);

So, I need the same value as found on Excel Worksheet **T.Inv** function.

How can i get same T.INV value in c#.

can anyone help me to get the same result please?

解决方案

This code returns both the left-tailed and the two tailed inverse of the Student's t-distribution

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);
}

P.S. I used the invstudenttdistribution function available here alglib.net

这篇关于使用C#的Excel公式T.INV计算错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆