Re: binomial distribution
- To: mathgroup at smc.vnet.net
- Subject: [mg16915] Re: [mg16895] binomial distribution
- From: BobHanlon at aol.com
- Date: Tue, 6 Apr 1999 01:27:38 -0400
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 4/5/99 3:52:02 AM, robert.wright4 at virgin.net writes: >Can someone explain how I can solve for 'c' or 'n' given the other variables >in this equation: its the binomial form for calculation the operating >characteristic in acceptance sampling. The problem is that 'c' and 'n' >are >discrete and therefore 'Findroot' or 'NSolve' do not work. > >The other problem is that it takes a long time to evaluate 'PrBinomial' >for >large 'c' and 'n'.... is there a better way of calculating? > > >\!\(PrBinomial[c_, \ n_, p_] := \ > Sum[\ Binomial[n, k]\ \(\((1 - p)\)\^k\) p\^\(n - k\), {k, 0, c}] // >N\) > Robert, PrBinomial[c_, n_, p_] := Evaluate[Sum[Binomial[n, k]*(1 - p)^k*p^(n - k), {k, 0, c}]] Note the use of Evaluate. x1 = PrBinomial[3,5,0.1]; FindRoot[PrBinomial[c,5,0.1]==x1, {c, 4, 5}] {c\[Rule]3.} FindRoot[PrBinomial[3,n,0.1]==x1, {n, 3, 4}] {n\[Rule]5.} x2 = PrBinomial[27,84,0.2]; If you know roughly what the solution should be you can limit the search. If not, check all values: IntegerQQ[x_] := Chop[x - Round[x]] == 0; eqn = PrBinomial[c,84,0.2]==x2; soln = Select[c /.Table[FindRoot[eqn, {c, k, k+1}], {k, 0, 83}], IntegerQQ[#]&] (* extraneous error messages removed *) {6.,7.,10.,11.,14.,19.,17.,19.,19.,22.,25.,25.,27.,35.} Rounding and eliminating duplicate solutions soln = Union[Round[soln]] {6,7,10,11,14,17,19,22,25,27,35} Picking the best discrete solution First[Sort[soln, Abs[PrBinomial[#1,84,0.2]-x2] < Abs[PrBinomial[#2,84,0.2]-x2]&]] 27 Bob Hanlon