LCHOOSE
Updated 2024-03-08 20:52:42.670000
Syntax
SELECT [westclintech].[wct].[LCHOOSE](
<@N, float,>
,<@K, float,>)
Description
Use the scalar function LCHOOSE to calculate the natural logarithm of the binomial coefficient.
\text{LCHOOSE}=\ln\frac{n!}{(n-k)!k!}
Arguments
@N
is any positive number. @N must be of a type float or of type that intrinsically converts to float.
@K
is any positive number. @K must be of a type float or of a type that intrinsically converts to float.
Return Type
float
Remarks
@N is truncated and the integer value is used.
@K is truncated and the integer value is used.
If @N < 0 then NULL is returned.
If @K < 0 then NULL is returned.
If @K > @N then NULL is returned.
Examples
SELECT wct.LCHOOSE( 25, --@N
15 --@k
) as LCHOOSE;
This produces the following result.
{"columns":[{"field":"LCHOOSE","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"LCHOOSE":"14.9999212660641"}]}
Using the EXP function with LCHOOSE will return the binomial coefficient.
SELECT EXP(wct.LCHOOSE(25, 15)) as LCHOOSE,
wct.BICO(25, 15) as BICO;
This produces the following result.
{"columns":[{"field":"LCHOOSE","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"},{"field":"BICO","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"LCHOOSE":"3268759.99999999","BICO":"3268760"}]}
See Also
COMBIN - Combinatorial function
FACTLN - natural logarithm of a factorial