MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: binomial distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16992] Re: binomial distribution
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Sat, 10 Apr 1999 02:13:31 -0400
  • Organization: University of Western Australia
  • References: <7e9ohv$3kq@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Robert Wright wrote:
 
> 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\)

Firstly, note that Mathematica can compute the sum in closed form:

In[1]:= pr[c_, n_, p_] = PowerExpand[FunctionExpand[
    Simplify[Sum[Binomial[n, k]*(1 - p)^k*p^(n - k), 
      {k, 0, c}]]]]

Out[1]=
          -c + n - 1
((p - 1) p           Gamma[n + 1] 
 
                                            p - 1         c
     Hypergeometric2F1[1, c - n + 1, c + 2, -----] (1 - p) )\
                                              p
 
    / (Gamma[c + 2] Gamma[n - c]) + 1

Numerical evaluation is now fast:

In[2]:= pr[1000, 1200, 0.3]
Out[2]= 0.999999999999999999999999994237542093921128937699427244989

In[3]:= pr[1000, 1500, 0.3]
Out[3]= 0.002844110551587560144702272926909

You can then plot this (continuous) function, e.g.,

In[4]:= Plot[Evaluate[pr[15, n, 0.6]], {n, 16, 60}]; 

Evaluate is used so that the expression is only computed once. You can
then use FindRoot to determine, say, n given c and p:

In[3]:= FindRoot[Evaluate[pr[15, n, 0.6]] == 0.8, {n, 20, 21}]
Out[3]= {n -> 32.8623}

Of course, you then need to round this result.

Cheers,
	Paul

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia           
Nedlands WA  6907                     mailto:paul at physics.uwa.edu.au 
AUSTRALIA                        http://www.physics.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


  • Prev by Date: Re: Eigenvalue Problem
  • Next by Date: Re: Eigenvalue Problem
  • Previous by thread: Re: Re: binomial distribution
  • Next by thread: Re: Help Defining Variables (with long names)