Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to calculate T.INV() in c# without excel workbook object. Is there any direct formula or class that can help me?.I have already Used "System.Web.UI.DataVisualization " namespace but it is not giving me expected result.
Thanks
Shakeb Khan

C#
public static double InverseTDistributionfun(int DF, double probability)
{
    double Tinv;
    try
    {
        chart.Charting.Chart objChart = new chart.Charting.Chart();
        Tinv = objChart.DataManipulator.Statistics.TDistribution(probability,DF, true);

        // value = c16 + dup * y30;

    }
    catch (Exception ex)
    {
        throw ex;
    }
    return Tinv;
}

[Microsoft.SqlServer.Server.SqlProcedure]
public static double SQLCLRCsharpSP(int DF, double probability)
{
    double _sum = 0.00;
    try
    {

        //if (type == "C")
        _sum = InverseTDistributionfun(DF, probability);
        //if (type == "A")
            //_sum = AlgTInvFun(probability, DF);
    }
    catch (Exception ex)
    {
        throw ex;
    }
    return  _sum;
}
Posted
Updated 22-Sep-14 2:22am
v3
Comments
BillWoodruff 22-Sep-14 8:07am    
You used the StatisticFormula.TDistribution Method in System.Web.UI.DataVisualization.Charting ?
shakeb@techwave 22-Sep-14 8:46am    
In excel
1.475884=T.INV(0.9,5) which is I am expecting.

but it gave me this result in .NET

1)0.20468560017491644
Tinv = objChart.DataManipulator.Statistics.TDistribution(.9, 5, true);
2)0.40937120034983288
Tinv = objChart.DataManipulator.Statistics.TDistribution(.9, 5, false);
shakeb@techwave 24-Sep-14 0:46am    
Please help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900