问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/53932658/excel-formula-t-inv-calculation-wrong-using-c-sharp