Logo

BINOMINV

Updated 2024-03-07 20:10:02.733000

Syntax

SELECT [westclintech].[wct].[BINOMINV] (
  <@P, float,>
 ,<@Trials, float,>
 ,<@Probability_s, float,>)

Description

Use the scalar function BINOMINV to calculate the value of the number of successes in the binomial distribution given the cumulative distribution function.

The cumulative distribution function is:

F(k;n,p) = \Pr(X \le k) = \sum_{i=0}^{\lfloor k \rfloor} {n\choose i}p^i(1-p)^{n-i}

Arguments

@P

is the value of the cumulative distribution function. @P is an expression of type float or of a type that implicitly converts to float.

@Probability_s

is the probability of success in each trial. @Probability_s is an expression of type float or of a type that implicitly converts to float.

@Trials

is the number of independent trials. @Trials is an expression of type float or of a type that implicitly converts to float.

Return Type

float

Remarks

@P must be greater than or equal to zero and less than or equal to 1 (0 = @P = 1).

@Probability_s must be greater than or equal to zero and less than or equal to 1 (0 = @Probability_s = 1).

@Trials must be greater than or equal to 1 (@Trials = 1).

@Trials is truncated to zero decimal places.

Examples

Calculate the cumulative distribution function:

SELECT wct.BINOMDIST(6, 10, 0.5, 'True');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.828125"}]}

Calculate the inverse of the cumulative distribution function:

SELECT wct.BINOMINV(0.828125, 10, 0.5);

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"6"}]}