Problem Note 64711: RAND function with BINOMIAL distribution and RANBIN function might return poor results if "n" is large
The RAND(‘BINOMIAL’, p, n) function and the RANBIN(seed, n, p) function might return pseudo-random variates that do not adequately follow the Binomial distribution if n is large and p approaches 0 or 1.
Under the following conditions, a Normal approximation to the Binomial distribution is used by the RAND and RANBIN functions:
- n > 300, and
- (n*p) > 5, and
- (n*(1-p)) > 5
Otherwise, the Inverse Transform method is used. The Normal approximation to the Binomial distribution does not perform well when p approaches 0 or 1.
To circumvent the problem when n > 300, you can compute the sum of several Binomial random variates with n ≤ 300. For example, instead of specifying:
X=Rand(‘BINOMIAL’, p, 700);
you can run the equivalent code below to define your Binomial random variable, X:
X1=Rand(‘BINOMIAL’, p, 300);
X2=Rand(‘BINOMIAL’, p, 300);
X3=Rand(‘BINOMIAL’, p, 100);
X = X1+X2+X3;
Note: This behavior is observed under the aforementioned conditions with the RAND(‘BINOMIAL’, p, n) function for all of the random-number generators supported in the CALL STREAMINIT<(RNG, seed)>; subroutine.
Operating System and Release Information
SAS System | Base SAS | z/OS | | |
z/OS 64-bit | | |
OpenVMS VAX | | |
Macintosh | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 8 Enterprise 32-bit | | |
Microsoft Windows 8 Enterprise x64 | | |
Microsoft Windows 8 Pro 32-bit | | |
Microsoft Windows 8 Pro x64 | | |
Microsoft Windows 8.1 Enterprise 32-bit | | |
Microsoft Windows 8.1 Enterprise x64 | | |
Microsoft Windows 8.1 Pro 32-bit | | |
Microsoft Windows 8.1 Pro x64 | | |
Microsoft Windows 10 | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 R2 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows Server 2012 Datacenter | | |
Microsoft Windows Server 2012 R2 Datacenter | | |
Microsoft Windows Server 2012 R2 Std | | |
Microsoft Windows Server 2012 Std | | |
Microsoft Windows Server 2016 | | |
Microsoft Windows Server 2019 | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
The RAND(‘BINOMIAL’,p,n) function and the RANBIN(seed,n,p) function might return pseudo-random variates that do not adequately follow the Binomial distribution if the parameter “n” is large and the parameter “p” approaches 0 or 1.
Type: | Problem Note |
Priority: | high |
Topic: | Analytics ==> Distribution Analysis Analytics ==> Simulation SAS Reference ==> Functions ==> Random Number ==> CALL RANBIN SAS Reference ==> Functions ==> Random Number ==> CALL STREAMINIT SAS Reference ==> Functions ==> Random Number ==> RANBIN SAS Reference ==> Functions ==> Random Number ==> RAND
|
Date Modified: | 2019-09-04 15:44:19 |
Date Created: | 2019-08-29 14:40:20 |