Re: Re: binomial distribution
- To: mathgroup at smc.vnet.net
- Subject: [mg16967] Re: [mg16915] Re: [mg16895] binomial distribution
- From: BobHanlon at aol.com
- Date: Thu, 8 Apr 1999 02:32:55 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Arnold, If you need precision, the evaluated form of the function can also provide it. Just use an exact (rational) number for p (i.e., 1/5 instead of 0.2 in this case). pts = PrBinomial[#,84,1/5]& /@ Range[20]; ListPlot[pts,PlotJoined->True,PlotRange->All]; This will slow it down. I suspect that the preferred method would depend on the specific application. For the problem given, a bigger mistake that I made was that I should have incremented the values of k by two rather than one, i.e., I should have used {k, 0, 83, 2}. This would have still hit all of the permissable integers except 84 (i.e., c = n, for which case, PrBinomial[n, n, p] = 1) as one of the starting values for the FindRoot. I could have also combined the Round step with the FindRoot step by using Cases rather than Select: soln = Cases[c /. Table[FindRoot[eqn, {c, k, k + 1}], {k, 0, 83, 2}], x_?IntegerQQ -> Round[x] ] Bob Hanlon In a message dated 4/7/99 12:29:17 PM, arnoldk at cam.wits.ac.za writes: >While using Evaluate may be fast I should point out that its highly inaccurate. >For example observe the zigzag effect from your function of > >lst= PrBinomial[#,84,0.2]& /@ Range[20] >ListPlot[%,PlotJoined->True,PlotRange->All] > >Using greater accuracy one gets the correct monotonicity of the graph: > >PrBinomial2[c_, n_, p_] := > N[Sum[Binomial[n, k]*(1 - p)^k*p^(n - k), > {k, 0, c}],25] > >lst= PrBinomial2[#,84,0.2]& /@ Range[20] > >ListPlot[%,PlotJoined->True,PlotRange->All] >