1
votes

So I want to get Critical Chi-Square Value using Significance level and Degrees of Freedom. I tried using MathNet.Numerics but couldn't find which method to use to get the Critical Chi-Square Value

This was the documentation I'm referring, any help on redirecting me to correct documentation would help.

How I calculate the value in Excel is by using the formula =CHISQ.INV.RT(A2,B2)

2

2 Answers

0
votes

The function you require is InvCDF(), it is used as follows:

MathNet.Numerics.Distributions.ChiSquared.InvCDF(degreesOfFreedom, probability);
0
votes

I could finally solve this problem, so I want to share how I solved it.

I used the MathNet library, and to use the same function of Excel you are providing you have to keep in mind a few things: in this library it does not exist =CHISQ.INV.RT itself, instead, in C#, you need to use InvCDF (the equivalent of =CHISQ.INV in Excel) but instead of using a probability parameter like 0.05, you have to use the opposite part of the interval (0, 1), so that parameter should be 0.95.

The logic of this is in the description of the functions in Excel.

  • "CHISQ.INV" description says "Returns the inverse of the left-tailed probability of the chi-squared distribution", this one is the equivalent of ChiSquared.InvCDF (C#).
  • "CHISQ.INV.RT" description says "Returns the inverse of the right-tailed probability of the chi-squared distribution", this one DOES NOT exist in the MathNet library.

Example:

In Excel you write

=CHISQ.INV.RT(0.05, 9)

In C# you write

ChiSquared.InvCDF(9, 0.95);

In both cases the answer will be 16.9189776

Note that the order of the parameters are switched.

I hope I could help with this.