Logo

CHISQ_INV_RT

Updated 2023-11-02 21:15:14.397000

Syntax

SELECT [westclintech].[wct].[CHISQ_INV_RT](
  <@Probability, float,>
 ,<@Degrees_freedom, float,>)

Description

Use the scalar function CHISQ_INV_RT to calculate the inverse of the right-tailed probability of a chi-squared distribution.

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 = 1 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_RT(   0.95, --@Probability

                           10    --@Degrees_freedom

                       ) as [X];

This produces the following result.

{"columns":[{"field":"X","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"X":"3.94029913611906"}]}

The chi-squared distribution is a special case of the gamma distribution.

SELECT wct.CHISQ_INV_RT(p, df) as [X],

       wct.INVGAMMAP(1 - p, 0.5 * df) * 2 as [X]

FROM

(

    VALUES

        (0.95, 10)

) n (p, df);

This produces the following result.

{"columns":[{"field":"X","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"X","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"X":"3.94029913611906"}]}

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_RT(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.

{"columns":[{"field":"df","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.99","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.95","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.90","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.75","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.50","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.25","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.10","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.05","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"0.01","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"df":"1","0.99":"0.000157087857909702","0.95":"0.00393214000001953","0.90":"0.0157907740934312","0.75":"0.101531044267621","0.50":"0.454936423119572","0.25":"1.32330369693146","0.10":"2.7055434540954","0.05":"3.84145882069412","0.01":"6.63489660102121"},{"df":"2","0.99":"0.0201006717070029","0.95":"0.102586588775101","0.90":"0.210721031315653","0.75":"0.575364144903562","0.50":"1.38629436111989","0.25":"2.77258872223978","0.10":"4.60517018598809","0.05":"5.99146454710798","0.01":"9.21034037197618"},{"df":"3","0.99":"0.114831801899117","0.95":"0.351846317749272","0.90":"0.584374374155183","0.75":"1.21253290304567","0.50":"2.36597388437534","0.25":"4.10834493563232","0.10":"6.25138863117033","0.05":"7.81472790325118","0.01":"11.3448667301444"},{"df":"4","0.99":"0.297109480506532","0.95":"0.710723021397324","0.90":"1.06362321677922","0.75":"1.92255752622955","0.50":"3.35669398003332","0.25":"5.38526905777939","0.10":"7.77944033973486","0.05":"9.48772903678115","0.01":"13.2767041359876"},{"df":"5","0.99":"0.554298076728277","0.95":"1.14547622606177","0.90":"1.61030798696232","0.75":"2.67460280943216","0.50":"4.35146019109553","0.25":"6.62567976382925","0.10":"9.23635689978112","0.05":"11.0704976935164","0.01":"15.086272469389"},{"df":"6","0.99":"0.872090330156587","0.95":"1.63538289432791","0.90":"2.20413065649864","0.75":"3.45459883572104","0.50":"5.34812062744712","0.25":"7.84080412058512","0.10":"10.6446406756684","0.05":"12.591587243744","0.01":"16.8118938297709"},{"df":"7","0.99":"1.23904230556793","0.95":"2.16734990929806","0.90":"2.83310691781534","0.75":"4.25485218354652","0.50":"6.34581119552152","0.25":"9.03714754790814","0.10":"12.0170366237805","0.05":"14.0671404493402","0.01":"18.4753069065824"},{"df":"8","0.99":"1.64649737269077","0.95":"2.73263679349966","0.90":"3.48953912564982","0.75":"5.07064042380018","0.50":"7.34412149770178","0.25":"10.2188549702468","0.10":"13.3615661365117","0.05":"15.5073130558655","0.01":"20.0902350296632"},{"df":"9","0.99":"2.08790073587073","0.95":"3.32511284306681","0.90":"4.1681590081461","0.75":"5.89882588296997","0.50":"8.34283269225295","0.25":"11.3887514404704","0.10":"14.6836565732598","0.05":"16.9189776046205","0.01":"21.6659943334619"},{"df":"10","0.99":"2.55821216018721","0.95":"3.94029913611906","0.90":"4.86518205192533","0.75":"6.73720077195464","0.50":"9.34181776559196","0.25":"12.5488613968894","0.10":"15.9871791721053","0.05":"18.3070380532751","0.01":"23.2092511589543"},{"df":"11","0.99":"3.05348410664068","0.95":"4.57481307932222","0.90":"5.57778478979985","0.75":"7.58414278544128","0.50":"10.3409980743918","0.25":"13.7006927460115","0.10":"17.2750085175001","0.05":"19.6751375726825","0.01":"24.7249703113183"},{"df":"12","0.99":"3.57056897060439","0.95":"5.22602948839264","0.90":"6.30379605958432","0.75":"8.43841876613579","0.50":"11.3403223774241","0.25":"14.8454036710402","0.10":"18.5493477867033","0.05":"21.0260698174831","0.01":"26.2169673055359"},{"df":"13","0.99":"4.1069154715044","0.95":"5.89186433770985","0.90":"7.04150458009545","0.75":"9.29906552985213","0.50":"12.3397558825639","0.25":"15.9839062163121","0.10":"19.8119293071276","0.05":"22.3620324948269","0.01":"27.6882496104571"},{"df":"14","0.99":"4.66042506265777","0.95":"6.57063138378935","0.90":"7.78953360975237","0.75":"10.1653138053771","0.50":"13.3392741490995","0.25":"17.1169335960001","0.10":"21.0641442129971","0.05":"23.6847913048406","0.01":"29.1412377406728"},{"df":"15","0.99":"5.22934888409896","0.95":"7.26094392767003","0.90":"8.54675624170454","0.75":"11.036537659091","0.50":"14.3388595109567","0.25":"18.2450856024151","0.10":"22.3071295815787","0.05":"24.9957901397286","0.01":"30.5779141668925"},{"df":"16","0.99":"5.81221247013497","0.95":"7.96164557237855","0.90":"9.312236353796","0.75":"11.912219697416","0.50":"15.3384988850016","0.25":"19.3688602205845","0.10":"23.5418289230961","0.05":"26.2962276048642","0.01":"31.9999269088152"},{"df":"17","0.99":"6.40775977773894","0.95":"8.67176020467008","0.90":"10.0851863346193","0.75":"12.791926423832","0.50":"16.3381823773925","0.25":"20.4886762383915","0.10":"24.7690353439014","0.05":"27.5871116382753","0.01":"33.4086636050046"},{"df":"18","0.99":"7.01491090117258","0.95":"9.39045508068899","0.90":"10.8649361165089","0.75":"13.6752903503983","0.50":"17.3379023687408","0.25":"21.6048897957282","0.10":"25.9894230826372","0.05":"28.8692994303926","0.01":"34.8053057347051"},{"df":"19","0.99":"7.63272964757147","0.95":"10.117013063859","0.90":"11.6509100321269","0.75":"14.5619967314202","0.50":"18.3376528967565","0.25":"22.7178067441998","0.10":"27.2035710293568","0.05":"30.1435272056462","0.01":"36.1908691292701"},{"df":"20","0.99":"8.2603983325464","0.95":"10.8508113941826","0.90":"12.4426092104501","0.75":"15.4517735390477","0.50":"19.3374292294283","0.25":"23.8276920430309","0.10":"28.4119805843056","0.05":"31.4104328442309","0.01":"37.5662347866251"},{"df":"22","0.99":"9.54249233878508","0.95":"12.3380145787907","0.90":"14.041493189422","0.75":"17.2396194047591","0.50":"21.3370448076727","0.25":"26.039265028165","0.10":"30.813282343953","0.05":"33.9244384714438","0.01":"40.2893604375938"},{"df":"24","0.99":"10.8563614755323","0.95":"13.8484250271702","0.90":"15.6586840525128","0.75":"19.0372525295236","0.50":"23.3367263060896","0.25":"28.2411500255287","0.10":"33.1962442886282","0.05":"36.4150285018073","0.01":"42.9798201393516"},{"df":"26","0.99":"12.1981469235056","0.95":"15.3791565832618","0.90":"17.2918849897388","0.75":"20.8434311030754","0.50":"25.3364581174773","0.25":"30.4345654286158","0.10":"35.5631712719235","0.05":"38.88513865983","0.01":"45.6416826662831"},{"df":"28","0.99":"13.5647097546188","0.95":"16.9278750444225","0.90":"18.9392423719175","0.75":"22.657155670646","0.50":"27.3362291986898","0.25":"32.6204940990255","0.10":"37.915922544697","0.05":"41.3371381514274","0.01":"48.2782357703155"},{"df":"30","0.99":"14.9534565284555","0.95":"18.4926609819535","0.90":"20.5992346145854","0.75":"24.4776076648863","0.50":"29.3360315166617","0.25":"34.7997425191409","0.10":"40.2560237387118","0.05":"43.7729718257422","0.01":"50.8921813115171"},{"df":"40","0.99":"22.1642612529752","0.95":"26.5093031966932","0.90":"29.0505229305456","0.75":"33.6602949229845","0.50":"39.3353448466115","0.25":"45.6160136189421","0.10":"51.8050572133175","0.05":"55.758479278887","0.01":"63.6907397515644"},{"df":"50","0.99":"29.7066826988413","0.95":"34.7642516835018","0.90":"37.6886483939786","0.75":"42.942083810906","0.50":"49.3349367339772","0.25":"56.3336049221323","0.10":"63.1671210057263","0.05":"67.5048065495411","0.01":"76.1538912490126"},{"df":"60","0.99":"37.4848515298038","0.95":"43.1879584539897","0.90":"46.4588883002034","0.75":"52.2938165837752","0.50":"59.3346662764426","0.25":"66.981461107619","0.10":"74.3970057193685","0.05":"79.0819444878487","0.01":"88.3794189014493"}]}

See Also

CHISQ_DIST - Lower chi-squared distribution

CHISQ_INV - Inverse of the chi-squared distribution

CHISQ_DIST_RT - Upper chi-squared distribution

INVGAMMAP - Calculate the inverse of the incomplete gamma functionP(a,x).