Project 29: Binomial Probability Distribution

Project 29: Variables 'n' and 'p' have been initialized.  There is also a working method available called binomialpdf.

n is the number of trials (3 in the example given)

p is probability of success on any trial (.3 in the example given)

binomialpdf(n,p,k) returns the probability of getting 'k' successes out of 'n' trials (if the probability of success on any trial is 'n').

Example: binomialpdf(3, .3,1) returns .441

Example: binomialpdf(3, .3,2) returns .189

Task: Appropriately initialize an array called 'binomialProbs'.  The array should hold the probabilities for each possible number of successes from least to greatest.

Example: If n = 3, and p = .3, the binomialProbs = [.343, .441, .189, .027].

Note: binomialProbs has been initialized as an empty array.  You can use the JS push method to add values to the end of the array

i.e. binomialProbs.push(3);    binomialProbs.push(4);   //binomialProbs = [3,4]

Note: If you are coding in Java, you can assume binomialProbs has already been declared and initialized as an empty ArrayList.

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0