47double nCr(
double n,
double r) {
49 double denominator = r;
51 for (
int i = n - 1; i >= ((n - r) + 1); i--) {
55 for (
int i = 1; i < r; i++) {
59 return numerator / denominator;
66 return nCr(n, x) * std::pow(p, x) * std::pow(1 - p, n - x);
77 for (
int i = lower_bound; i <= upper_bound; i++) {
78 probability +=
nCr(n, i) * std::pow(p, i) * std::pow(1 - p, n - i);
90 std::cout <<
"standard deviation : "
96 std::cout <<
"45 or more successes : "
double binomial_x_successes(double n, double p, double x)
double binomial_expected(double n, double p)
double binomial_range_successes(double n, double p, double lower_bound, double upper_bound)
double nCr(double n, double r)
double binomial_variance(double n, double p)
double binomial_standard_deviation(double n, double p)