Login     Register

        Contact Us     Search

XLeratorDB/statistics Documentation

SQL Server CHISQ.INV function


CHISQ_INV

Updated: 31 July 2015

Use CHISQ_INV to calculate the inverse of the left-tailed probability of a chi-squared distribution.
Syntax
SELECT [wct].[CHISQ_INV](
  <@Probability, float,>
 ,<@Degrees_freedom, float,>)
Arguments
@Probability
The value of interest to be evaluated. @Probability must be of a type float or of type that intrinsically converts to float
@Degrees_freedom
The number of degrees freedom. @Degrees_freedom must be of a type float or of a type that intrinsically converts to float.
Return Type
float
Remarks
·         0 = @Probability < 1
·         0 < @Degrees_freedom
·         If @Probability = 0 then 0 is returned
Examples
In this example we calculate inverse of the chi-squared distribution with probability 0.975 and 10 degrees of freedom.
SELECT
       wct.CHISQ_INV(
               0.95         --@Probability
              ,10           --@Degrees_freedom
              ) as [X]

This produces the following result
 


The chi-squared distribution is a special case of the gamma distribution
SELECT
        wct.CHISQ_INV(p,df) as [X]
       ,wct.INVGAMMAP(p,0.5*df)*2 as [X]
FROM (VALUES(0.95,10))n(p,df)

This produces the following result.


This example returns a table of critical values for the distribution.
SELECT
       df,[0.99],[0.95],[0.90],[0.75],[0.50],[0.25],[0.10],[0.05],[0.01]
FROM (
       SELECT
               df
              ,p
              ,wct.CHISQ_INV(p,df) as x
       FROM
              (VALUES (0.99),(0.95),(0.90),(0.75),(0.50),(0.25),(0.10),(0.05),(0.01))n(p)
       CROSS APPLY
              (VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16),(17),(18),(19),(20),(22),(24),(26),(28),(30),(40),(50),(60))m(df)
       )p
PIVOT(
       max(x)
       FOR p IN([0.99],[0.95],[0.90],[0.75],[0.50],[0.25],[0.10],[0.05],[0.01])
       ) d

This produces the following result.

 

See Also

 



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service