CHISQ_INV
Updated 2023-11-02 21:11:42.813000
Syntax
SELECT [westclintech].[wct].[CHISQ_INV](
<@Probability, float,>
,<@Degrees_freedom, float,>)
Description
Use the scalar function CHISQ_INV to calculate the inverse of the left-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 = 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.
{"columns":[{"field":"X","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"X":"18.3070380532751"}]}
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.
{"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":"18.3070380532751"}]}
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.
{"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":"6.63489660102121","0.95":"3.84145882069412","0.90":"2.7055434540954","0.75":"1.32330369693146","0.50":"0.454936423119572","0.25":"0.101531044267621","0.10":"0.0157907740934312","0.05":"0.00393214000001952","0.01":"0.000157087857909702"},{"df":"2","0.99":"9.21034037197618","0.95":"5.99146454710798","0.90":"4.60517018598809","0.75":"2.77258872223978","0.50":"1.38629436111989","0.25":"0.575364144903562","0.10":"0.210721031315653","0.05":"0.102586588775101","0.01":"0.0201006717070029"},{"df":"3","0.99":"11.3448667301444","0.95":"7.81472790325118","0.90":"6.25138863117033","0.75":"4.10834493563232","0.50":"2.36597388437534","0.25":"1.21253290304567","0.10":"0.584374374155183","0.05":"0.351846317749272","0.01":"0.114831801899117"},{"df":"4","0.99":"13.2767041359876","0.95":"9.48772903678115","0.90":"7.77944033973486","0.75":"5.38526905777939","0.50":"3.35669398003332","0.25":"1.92255752622955","0.10":"1.06362321677922","0.05":"0.710723021397324","0.01":"0.297109480506532"},{"df":"5","0.99":"15.086272469389","0.95":"11.0704976935164","0.90":"9.23635689978112","0.75":"6.62567976382925","0.50":"4.35146019109553","0.25":"2.67460280943216","0.10":"1.61030798696232","0.05":"1.14547622606177","0.01":"0.554298076728277"},{"df":"6","0.99":"16.8118938297709","0.95":"12.591587243744","0.90":"10.6446406756684","0.75":"7.84080412058512","0.50":"5.34812062744712","0.25":"3.45459883572104","0.10":"2.20413065649864","0.05":"1.63538289432791","0.01":"0.872090330156586"},{"df":"7","0.99":"18.4753069065824","0.95":"14.0671404493402","0.90":"12.0170366237805","0.75":"9.03714754790814","0.50":"6.34581119552152","0.25":"4.25485218354652","0.10":"2.83310691781534","0.05":"2.16734990929806","0.01":"1.23904230556793"},{"df":"8","0.99":"20.0902350296632","0.95":"15.5073130558655","0.90":"13.3615661365117","0.75":"10.2188549702468","0.50":"7.34412149770178","0.25":"5.07064042380018","0.10":"3.48953912564982","0.05":"2.73263679349966","0.01":"1.64649737269077"},{"df":"9","0.99":"21.6659943334619","0.95":"16.9189776046205","0.90":"14.6836565732598","0.75":"11.3887514404704","0.50":"8.34283269225295","0.25":"5.89882588296997","0.10":"4.16815900814611","0.05":"3.32511284306681","0.01":"2.08790073587073"},{"df":"10","0.99":"23.2092511589543","0.95":"18.3070380532751","0.90":"15.9871791721053","0.75":"12.5488613968894","0.50":"9.34181776559196","0.25":"6.73720077195464","0.10":"4.86518205192533","0.05":"3.94029913611906","0.01":"2.55821216018721"},{"df":"11","0.99":"24.7249703113183","0.95":"19.6751375726825","0.90":"17.2750085175001","0.75":"13.7006927460115","0.50":"10.3409980743918","0.25":"7.58414278544128","0.10":"5.57778478979985","0.05":"4.57481307932222","0.01":"3.05348410664068"},{"df":"12","0.99":"26.2169673055359","0.95":"21.0260698174831","0.90":"18.5493477867033","0.75":"14.8454036710402","0.50":"11.3403223774241","0.25":"8.43841876613579","0.10":"6.30379605958432","0.05":"5.22602948839264","0.01":"3.57056897060439"},{"df":"13","0.99":"27.6882496104571","0.95":"22.3620324948269","0.90":"19.8119293071276","0.75":"15.9839062163121","0.50":"12.3397558825639","0.25":"9.29906552985213","0.10":"7.04150458009546","0.05":"5.89186433770984","0.01":"4.1069154715044"},{"df":"14","0.99":"29.1412377406728","0.95":"23.6847913048406","0.90":"21.0641442129971","0.75":"17.1169335960001","0.50":"13.3392741490995","0.25":"10.1653138053771","0.10":"7.78953360975237","0.05":"6.57063138378935","0.01":"4.66042506265777"},{"df":"15","0.99":"30.5779141668925","0.95":"24.9957901397286","0.90":"22.3071295815787","0.75":"18.2450856024151","0.50":"14.3388595109567","0.25":"11.036537659091","0.10":"8.54675624170455","0.05":"7.26094392767003","0.01":"5.22934888409896"},{"df":"16","0.99":"31.9999269088152","0.95":"26.2962276048642","0.90":"23.5418289230961","0.75":"19.3688602205845","0.50":"15.3384988850016","0.25":"11.912219697416","0.10":"9.312236353796","0.05":"7.96164557237855","0.01":"5.81221247013496"},{"df":"17","0.99":"33.4086636050046","0.95":"27.5871116382753","0.90":"24.7690353439014","0.75":"20.4886762383915","0.50":"16.3381823773925","0.25":"12.791926423832","0.10":"10.0851863346193","0.05":"8.67176020467008","0.01":"6.40775977773894"},{"df":"18","0.99":"34.8053057347051","0.95":"28.8692994303926","0.90":"25.9894230826372","0.75":"21.6048897957282","0.50":"17.3379023687408","0.25":"13.6752903503983","0.10":"10.8649361165089","0.05":"9.39045508068898","0.01":"7.01491090117258"},{"df":"19","0.99":"36.1908691292701","0.95":"30.1435272056462","0.90":"27.2035710293568","0.75":"22.7178067441998","0.50":"18.3376528967565","0.25":"14.5619967314202","0.10":"11.6509100321269","0.05":"10.117013063859","0.01":"7.63272964757147"},{"df":"20","0.99":"37.5662347866251","0.95":"31.4104328442309","0.90":"28.4119805843056","0.75":"23.8276920430309","0.50":"19.3374292294283","0.25":"15.4517735390477","0.10":"12.4426092104501","0.05":"10.8508113941826","0.01":"8.2603983325464"},{"df":"22","0.99":"40.2893604375938","0.95":"33.9244384714438","0.90":"30.813282343953","0.75":"26.039265028165","0.50":"21.3370448076727","0.25":"17.2396194047591","0.10":"14.041493189422","0.05":"12.3380145787907","0.01":"9.54249233878508"},{"df":"24","0.99":"42.9798201393516","0.95":"36.4150285018073","0.90":"33.1962442886282","0.75":"28.2411500255287","0.50":"23.3367263060896","0.25":"19.0372525295236","0.10":"15.6586840525128","0.05":"13.8484250271702","0.01":"10.8563614755323"},{"df":"26","0.99":"45.6416826662831","0.95":"38.88513865983","0.90":"35.5631712719235","0.75":"30.4345654286158","0.50":"25.3364581174773","0.25":"20.8434311030754","0.10":"17.2918849897388","0.05":"15.3791565832617","0.01":"12.1981469235056"},{"df":"28","0.99":"48.2782357703155","0.95":"41.3371381514274","0.90":"37.915922544697","0.75":"32.6204940990255","0.50":"27.3362291986898","0.25":"22.657155670646","0.10":"18.9392423719175","0.05":"16.9278750444225","0.01":"13.5647097546188"},{"df":"30","0.99":"50.8921813115171","0.95":"43.7729718257422","0.90":"40.2560237387118","0.75":"34.7997425191409","0.50":"29.3360315166617","0.25":"24.4776076648863","0.10":"20.5992346145854","0.05":"18.4926609819535","0.01":"14.9534565284554"},{"df":"40","0.99":"63.6907397515644","0.95":"55.758479278887","0.90":"51.8050572133175","0.75":"45.6160136189421","0.50":"39.3353448466115","0.25":"33.6602949229845","0.10":"29.0505229305455","0.05":"26.5093031966931","0.01":"22.1642612529752"},{"df":"50","0.99":"76.1538912490126","0.95":"67.5048065495411","0.90":"63.1671210057263","0.75":"56.3336049221323","0.50":"49.3349367339772","0.25":"42.942083810906","0.10":"37.6886483939786","0.05":"34.7642516835018","0.01":"29.7066826988413"},{"df":"60","0.99":"88.3794189014493","0.95":"79.0819444878487","0.90":"74.3970057193685","0.75":"66.981461107619","0.50":"59.3346662764426","0.25":"52.2938165837752","0.10":"46.4588883002034","0.05":"43.1879584539898","0.01":"37.4848515298038"}]}
See Also
CHISQ_DIST - Lower chi-squared distribution
CHISQ_INV_RT - Calculate the inverse of the right-tailed probability of a chi-squared distribution.
CHISQ_DIST_RT - Upper chi-squared distribution
INVGAMMAP - Calculate the inverse of the incomplete gamma functionP(a,x).