Pregunta

I am porting over some code from Microsoft Excel to C#. The Excel expression uses the TINV function. Is there an equivalent function in C# or .NET? If not, what C# code is necessary to reimplement this function?

¿Fue útil?

Solución

If you are using .NET 4.0 you can leverage the Chart class found in the System.Web.DataVisualization assembly (you will also need to add System.Web). E.G:

var chart = new System.Web.UI.DataVisualization.Charting.Chart();
double result = chart.DataManipulator.Statistics.InverseTDistribution(.05, 15);

//2.131449546

Documentation:

http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.statisticformula.inversetdistribution(v=vs.110).aspx

Otros consejos

Necromancing.

You can look the exact way up in Math.NET (MIT/X11).

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

which is the same as:

double result  = -StudentT.InvCDF(0d, 1d, degFreedom, probability/2);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top