BookmarkSubscribeRSS Feed
topkatz
Obsidian | Level 7
(originally posted on SAS-L)

Hi.

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?

Thanks!

-- TMK --
t o p k a t z @ m s n . c o m
2 REPLIES 2
topkatz
Obsidian | Level 7
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).
Rick_SAS
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 841 views
  • 0 likes
  • 2 in conversation