MathGroup Archive 2002

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

Search the Archive

Re: binomial distribution

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33670] Re: [mg33658] binomial distribution
  • From: "Johannes Ludsteck" <johannes.ludsteck at wiwi.uni-regensburg.de>
  • Date: Sat, 6 Apr 2002 00:48:44 -0500 (EST)
  • Organization: Universitaet Regensburg
  • Sender: owner-wri-mathgroup at wolfram.com

Dear Nadia,
you seem to be one of the millions of users trying
to obtain good answers to *bad* questions!
How should someone answer your question if he does
not know
1) How large were N and X[[N]] when the error
	message was given, was it 500 or 10^20?
2) how is p defined?
3) Which program do you use to generate the lists,
	Nest, FoldList, Do, For?


By the way: X[[n]] may increase rapidly
(of course, depending on the definition of p).
Thus, if for example X[[n]] == 1000, it becomes
computationally very demanding to draw 'good' random
numbers from a binomial distribution.
(If you are interested in the details,
have a look at the Package where
the random draws are programmed.
A simple algorithm is to make thousand (!)
draws from a Bernoulli Distribution with
parameter p.) 
However, it is **highly!** inefficient to
draw from a binomial distribution if X[[n]] > 100,
since (you should have learned this in
an introductory statistics course)
the binomial distribution converges rapidly
to a normal distribution
and it is computationally very 'cheap'
to draw from a normal distribution. Thus
you simply have to transform the binomial distribution
to a normal if X > 100 or so.

When I replicate your what you *probably* did, I obtain

In[1]:=
p=Table[Random[Real,{0.1,0.5}],{40}];

In[2]:=
FoldList[
  #1+Random[BinomialDistribution[#1,#2]]&,1,p]

Out[2]=
{1,1,1,1,1,1,1,1,1,1,2,3,3,3,4,4,6,8,8,9,
	10,11,14,19,26,36,43,55,75,94,122,166,210,
	268,396,564,640,831,1187,1757,2068}

Though my values in p are between 0.1 and 0.5 and
X[[1]] = 1, X[[40]] is larger than 2000.
Therefore I advise you to use the normal distribution
transformation.

Best regards,
	Johannes




On 4 Apr 2002, at 19:40, Nadia Lalam wrote:

Hello,

I have to define a sequence recursively with the binomial distribution
in the following way :

X[[n+1]]=X[[n]]+Random[BinomialDistribution[X[[n]],p[[n]]], n ranging
from 1 to some N 

The first terms of the sequence are well constructed with Mathematica
but as X[[n]] grows, I had the message 

Internal counter overflow.
Some expression evaluations may not run to their
final fixed points.  Try redoing your computation
on a 64-bit enhanced version of Mathematica.

Could you tell me how to solve this problem?

Thanks in advance,

Nadia



  • Prev by Date: Re: Beginner question on local vars./scoping
  • Next by Date: RE: WorldGraphics Question
  • Previous by thread: binomial distribution
  • Next by thread: HTMLSave