HYPGEOM_INV
Updated 2023-11-03 14:20:51.470000
Syntax
SELECT [westclintech].[wct].[HYPGEOM_INV](
<@P, float,>
,<@Number_sample, float,>
,<@Population_s, float,>
,<@Number_population, float,>)
Description
Use the scalar function HYPGEOM_INV to calculate the quantiles of the hypergeometric distribution. The hypergeometric distribution is generally described using colored balls in an urn. Given an urn containing N balls of which K are white (and N-K are black), the hypergeometric distribution calculates the probability of drawing k white balls from a sample of n without replacement (meaning that once a ball is removed from the urn it is not put back).
Arguments
@Number_population
the size of the population. @Number_population must be of a type float or of a type that intrinsically converts to float.
@P
the probability value to be evaluated. @P must be of a type float or of type that intrinsically converts to float.
@Number_sample
the size of the sample. @Number_sample must be of a type float or of type that intrinsically converts to float.
@Population_s
the number of successes in the population. @Population_s must be of a type float or of type that intrinsically converts to float.
Return Type
float
Remarks
@Number_sample, @Population_s, and @Number_population are truncated; only the integer part is used.
0 ≤ @P ≤ 1.
0 ≤ @Population_s
0 < @Number_sample
0 < @Number_population
@Population_s ≤ @Number_population.
Examples
In an urn with 1000 balls of which 300 are white we want to calculate the number of while balls we should expect in a random sample of 25 balls 95% of the time.
SELECT wct.HYPGEOM_INV( 0.95, --@P
25, --@Sample_s
300, --@Population_s
1000 --@Number_Population
) as HYPGEOM_INV;
This produces the following result.
{"columns":[{"field":"HYPGEOM_INV","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"HYPGEOM_INV":"11"}]}
In other words, in a random sample of 25 balls, we would expect to have no more than 11 white balls 95% of the time.