FUNCTION
CDF
Evaluates the binomial distribution CDF.
You're viewing an older version of this page (#174). View the current version.
Interface
#include <codecogs/statistics/distributions/discrete/binomial/cdf.h>
using namespace Statistics::Distributions::Discrete::Binomial;
Evaluates the binomial distribution CDF:
(1)
\graph k=1 n=2:10:5 p=0:1
Example:
#include <stdio.h>
#include <codecogs/statistics/distributions/discrete/binomial/cdf.h>
int main()
{
int k[10] = { 1, 2, 9, 9, 1, 0, 2, 1, 6, 8 };
int n[10] = { 2, 4, 10, 14, 5, 2, 10, 1, 10, 18 };
double p[10] = { 0.5, 0.5, 0.5, 0.6, 0.1, 0.4, 0.9, 0.1, 0.1, 0.4 };
for( int i=0; i<10; i++ )
{
printf( "CDF(%i, %i, %1.1f, true) = %f \n",
k[i], n[i], p[i], Stats::Dists::Discrete::Binomial::CDF( k[i], n[i], p[i], true ) );
}
return getchar();
}
Output:
CDF(1, 2, 0.5, true) = 0.250000
CDF(2, 4, 0.5, true) = 0.312500
CDF(9, 10, 0.5, true) = 0.000977
CDF(9, 14, 0.6, true) = 0.279257
CDF(1, 5, 0.1, true) = 0.081460
CDF(0, 2, 0.4, true) = 0.640000
CDF(2, 10, 0.9, true) = 1.000000
CDF(1, 1, 0.1, true) = 0.000000
CDF(6, 10, 0.1, true) = 0.000009
CDF(8, 18, 0.4, true) = 0.263159
Accuracy:
Tested at random points (a,b,p).
p a,b domain # trials peak rms
0.001 to 1 0,100 100000 6.7e-15 8.2e-16
0 to 0.001 0,100 100000 1.5e-13 2.7e-15
Parameters
k
the maximum number of successes
n
the total number of trials, must be >= k
p
the probability of success for each trial, must be in range 0..1
upper
Default value = false
Returns
the value of the upper or lower tail of the binomial CDF with the given arguments
Interactive Calculator
k
n
p
upper
Result
Computing…
Set a range above first to export a graph.
This function's source code is only visible to registered users — documentation and the calculator above are free to use either way. Sign in to see it.