Topic: Some trouble with the sum function.
Hello,
I'm trying to use the sum function to sum a bunch of binomial distributions together, and the factorial functions seems to break when its used inside the sum function, at least in some situations. I have attached a file to illustrate the problem.
The first few functions in the file are an example of what I'm trying to automate using the sum function. The custom functions in the file are:
1. nchoosek(n,k) the binomail coeficcient.
2. bin(k,n,p) the binomial distribution for k successes in n trials, with p probability per trial. This uses the nchoosek function.
3. perbin(k,n,p) makes the probabilities into percents by passing p/100 to bin() and returning 100* the answer.
4. sums(n,k,p). This uses the sum function to sum the perbin function over values of k from 0 to k. The result is supposed to be the probability of achieving k or fewer successes in n trials.
5. sums2(k,n,p) Same as above, but instead of using nested functions, it's all in one giant lump in one function. This version actually works, despite the fact that it should be doing exactly the same thing as the above function.
Check out the file and this will all make more sense. Can anyone figure out what's going on here?
Thanks!
-James