BINOMDIST
Updated 2024-03-07 20:08:42.993000
Syntax
SELECT [westclintech].[wct].[BINOMDIST] (
<@Number_s, float,>
,<@Trials, float,>
,<@Probability_s, float,>
,<@Cumulative, bit,>)
Description
Use the scalar function BINOMDIST to calculate the binomial distribution. The binomial distribution is the discrete probability distribution of the number of successes in a sequence of n independent yes/no experiments, each of which yields success with probability p. The formula for the probability mass function is:
Pr(X=k)=\binom{n}{k}p^k(1-p)^{n-k}
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
@Number_s
is the number of successes in trials. @Number_s is an expression of type float or of a type that can be implicitly converted to float.
@Cumulative
is a logical value that determines the probability density function (False, 0) or the cumulative distribution function (True, 1) is being calculated.
@Probability_s
is the probability of success in each trail. @Probability_s is an expression of type float or of a type that can be implicitly converted to float.
@Trials
is the number of independent trials. @Trials is an expression of type float or of a type that can be implicitly converted to float.
Return Type
float
Remarks
@Number_s and @Trials are truncated to zero decimal places.
If @Number_s, @Trials, or @Probability_s <0, BINOMDIST returns an error.
If @Number_s > @Trials, BINOMDIST returns an error.
If @Probability_s > 1, BINOMDIST returns an error.
If @Cumulative = False then BINOMDIST =
BICO(@Trials,@trials-@number_s) * POWER(@Probability_s,@Number_s) * POWER((1-@Probability_s),(@Trials-@Number_s))
If @Cumulative = True then BINOMDIST =
1-BETADIST(@Probability_s, @Number_s+1, @Trials-@Number_s, NULL, NULL)
Examples
select wct.BINOMDIST(6, 10, .5, 'False');
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.205078125000001"}]}
select wct.BICO(10, 10 - 6) * POWER(.500000000, 6.00000000) * POWER(1.00000000 -
.500000000, 10.0000000 - 6.0000000);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.205078125"}]}
select wct.BINOMDIST(6, 10, .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"}]}
select 1 - wct.betadist(.5, 6 + 1, 10 - 6, null, null);
This produces the following result.
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.828124999999999"}]}