2014-09-22 54 views
1

如何在沒有Excel工作簿對象的情況下計算c#中的T.INV()。有沒有可以幫助我的直接公式或類?我已經使用過「System.Web.UI.DataVisualization」命名空間,但它沒有給我預期的結果。 感謝 Shakeb汗如何在沒有Excel工作簿對象的c#中計算T.INV()

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; 
} 
+0

你可以顯示你正在嘗試使用的代碼嗎? – doctorlove 2014-09-22 12:04:36

+0

這是否是http://stackoverflow.com/questions/20963192/c-sharp-equivalent-of-excels-tinv-function的重複? – doctorlove 2014-09-22 12:06:22

+0

它不重複TINV()和T.INV()是不同的功能。它在Excel 2010以後的版本中引入。 – 2014-09-22 12:13:57

回答

0

你可以看一下確切一路在Math.NET(MIT/X11)。

double result = MathNet.Numerics.ExcelFunctions.TInv (probability, degFreedom); 

這是相同的:

double result = -StudentT.InvCDF(0d, 1d, degFreedom, probability/2); 

您找到完整的解決方案here。 如果那不返回相同的值,那麼你沒有使用tinv函數。

相關問題