Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C++ language please, using looping/ functions or anything. recursive or itera

ID: 3761908 • Letter: I

Question

In C++ language please, using looping/ functions or anything. recursive or iterate functions

The binomial distribution consists of the probabilities of each of the possible numbers of successes on N trials for independent events that each have a probability of p of occurring. For the coin flip example, N = 2 and p = 0.5. The formula for the binomial distribution is shown below:

P(x)= (N!/(x!(N-x)!))((p^x)(1-p)^(N-x))

Requirement 1: Write a C++ program to compute the binomial probability: when the user types in a value for N (an integer), x (an integer which can be between 0 and N), and p (a positive real number between 0 and 1).

Requirement 2: The program should compute the sum of probabilities within a given range typed in by the user (i.e. the program can ask the user to input the low end of the value of x and high end of the value of x). For example P(0<=x<=3) = P(x=0)+P(x=1)+P(x=2)+P(x=3).

Explanation / Answer

#include #include #include #include #include #include using namespace std; //Binomial Distribution Calculator double factorial(double number) //finds factorials { if (number == 1) return 1; return factorial(number - 1)*number; } double bernoulli(int x, int n, double p) //bernoulli function { return ((factorial(n))/(factorial(x)*(factorial(n-x))))*(pow(p,x))*(pow((1-p),(n-x))); } double bidis(int x, int r, int n, double p) //sums bernoulli to give binomial distribution { double sum = 0; for (int i = x; i < (r+1); i = i+1) sum = sum + bernoulli(i, n, p); return (sum); } int main() { double result; result = bidis(3, 8, 15, .4); //input your lower x, upper x(r), total number (n), and probability (p) cout