Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Ranbin performance

Posts: 27

Ranbin performance

(originally posted on SAS-L)


I am doing some very large binomial distribution simulations using ranbin in SAS 9.1.3 on Windows XP, and I'm interested in comparing notes with other ranbin users.

I have learned some interesting things about ranbin that I haven't seen in the documentation. It appears that the largest allowed value of N is (2**31 - 1). It appears that the smallest allowed value of p is around (1E-323). I've gotten errors outside these ranges.

In the documentation for ranbin it does say that the normal approximation with mean N*p and variance N*p*(1-p) is used when N > 50 and min(N*p,N*(1-p)) > 5. I have been getting very, very slow performance from ranbin. When I explicitly substitute rannor under the conditions given (N > 50 and min(N*p,N*(1-p)) > 5), I get similar (not identical) numerical results, but orders of magnitude faster. I am thinking of chucking ranbin altogether and just using a combination of rannor and ranpoi.

Has anyone else found such slow performance from ranbin? Any suggestions on how to handle it? Has anyone had a good experience with ranbin?


-- TMK --
t o p k a t z @ m s n . c o m
Posts: 27

Re: Ranbin performance

I submitted this to SAS tech support (tracking number 7610166978) and got an excellent suggestion from tech support representative Phil Gibbs. The rand('BINOMIAL',p,n) function is much faster than ranbin(seed,n,p). Also, while rand has the same upper bound for n (2**31 - 1) as ranbin, it seems to work for any p between 0 and 1, whereas ranbin doesn't work at the extremes of p. Just note that if you want to control the seeding, you need to use call streaminit(seed).
Posts: 3,306

Re: Ranbin performance

This is issue #5 on my list, which applies to all of the old RAN*** functions in SAS:

Six reasons you should stop using the RANUNI function to generate random numbers - The DO Loop

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation