SAS Optimization, and SAS Simulation Studio

turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

12-18-2008 05:08 PM

(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

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to topkatz

12-19-2008 03:35 PM

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).

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to topkatz

02-03-2014 10:25 AM

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