Developer Reference

Contents

Random Number Generators Naming Conventions

The names of the routines, types, and constants in VS random number generators are case-sensitive and can contain lowercase and uppercase characters (
viRngUniform
).
The names of generator routines have the following structure:
v
<
type of result
>
Rng
<
distribution
>
 
 
 
where
  • v
    is the prefix of a VS vector function.
  • <
    type of result
    > is either
    s
    ,
    d
    , or
    i
    and specifies one of the following types:
    s
    float
    d
    double
    i
    int
    Prefixes
    s
    and
    d
    apply to continuous distributions only, prefix
    i
    applies only to discrete case.
  • rng
    indicates that the routine is a random generator.
  • <distribution>
    specifies the type of statistical distribution.
Names of service routines follow the template below:
vsl
<
name
>
where
  • vsl
    is the prefix of a VS service function.
  • <name>
    contains a short function name.
For a more detailed description of service routines, refer to Service Routines and Advanced Service Routines.
The prototype of each generator routine corresponding to a given probability distribution fits the following structure:
status = <
function name
>(
method
,
stream
,
n
,
r
, [<
distribution parameters
>] )
where
  • method
    defines the method of generation. A detailed description of this parameter can be found in table
    "Values of
    <
    method
    >
    in
    method
    parameter"
    . See
    below
    , where the structure of the
    method
    parameter name is explained.
  • stream
    defines the descriptor of the random stream and must have a non-zero value. Random streams, descriptors, and their usage are discussed further in Random Streams and Service Routines.
  • n
    defines the number of random values to be generated. If
    n
    is less than or equal to zero, no values are generated. Furthermore, if
    n
    is negative, an error condition is set.
  • r
    defines the destination array for the generated numbers. The dimension of the array must be large enough to store at least
    n
    random numbers.
  • status
    defines the error status of a VS routine. See Error Reporting for a detailed description of error status values.
Additional parameters included into
<distribution parameters>
field are individual for each generator routine and are described in detail in Distribution Generators.
To invoke a distribution generator, use a call to the respective VS routine. For example, to obtain a vector
r
, composed of
n
independent and identically distributed random numbers with normal (Gaussian) distribution, that have the mean value
a
and standard deviation
sigma
, write the following:
status
=
vsRngGaussian
(
method
,
stream
,
n
,
r
,
a
,
sigma
)
The name of a
method
parameter has the following structure:
VSL_RNG_METHOD_
method
<
distribution
>_<
method
>
VSL_RNG_METHOD_
<
distribution
>_<
method
>_
ACCURATE
where
  • <
    distribution
    >
    is the probability distribution.
  • <
    method
    >
    is the method name.
Type of the name structure for the
method
parameter corresponds to fast and accurate modes of random number generation (see "Distribution Generators" and VS Notes for details).
Method names
VSL_RNG_METHOD_<
distribution
>_<
method
>
and
VSL_RNG_METHOD_<
distribution
>_<
method
>_
ACCURATE
should be used with
v
<
precision
>
Rng
<
distribution
>
function only, where
  • <
    precision
    > is
    s
    for single precision continuous distribution
    d
    for double precision continuous distribution
    i
    for discrete distribution
  • <
    distribution
    >
    is the probability distribution.
is the probability distribution.Table
"Values of
<
method
>
in
method
parameter"
provides specific predefined values of the
method
name. The third column contains names of the functions that use the given method.
Values of
<
method
>
in
method
parameter
Method
Short Description
Functions
STD
Standard method. Currently there is only one method for these functions.
BOXMULLER
BOXMULLER
generates normally distributed random number
x
thru the pair of uniformly distributed numbers
u
1
and
u
2
according to the formula:
Equation
BOXMULLER2
BOXMULLER2
generates normally distributed random numbers
x
1
and
x
2
thru the pair of uniformly distributed numbers
u
1
and
u
2
according to the formulas:
Equation
Equation
ICDF
Inverse cumulative distribution function method.
GNORM
For
α
> 1, a gamma distributed random number is generated as a cube of properly scaled normal random number; for 0.6
α
< 1, a gamma distributed random number is generated using rejection from Weibull distribution; for
α
< 0.6, a gamma distributed random number is obtained using transformation of exponential power distribution; for
α
= 1, gamma distribution is reduced to exponential distribution.
CJA
For
min
(
p
,
q
) > 1
, Cheng method is used; for
min
(
p
,
q
) < 1
, Johnk method is used, if
q
+
K
·
p
2
+
C
0
(
K
= 0.852...,
C
=-0.956...) otherwise, Atkinson switching algorithm is used; for
max
(
p
,
q
) < 1
, method of Johnk is used; for
min
(
p
,
q
) < 1,
max
(
p
,
q
)> 1
, Atkinson switching algorithm is used (CJA stands for the first letters of Cheng, Johnk, Atkinson); for
p
= 1
or
q
= 1
, inverse cumulative distribution function method is used;for
p
= 1 and
q
= 1
, beta distribution is reduced to uniform distribution.
BTPE
Acceptance/rejection method for
ntrial
·min(
p
,1 -
p
)
30
with decomposition into 4 regions:
  • 2 parallelograms
  • triangle
  • left exponential tail
  • right exponential tail
H2PE
Acceptance/rejection method for large mode of distribution with decomposition into 3 regions:
  • rectangular
  • left exponential tail
  • right exponential tail
PTPE
Acceptance/rejection method for
λ
27 with decomposition into 4 regions:
  • 2 parallelograms
  • triangle
  • left exponential tail
  • right exponential tail;
otherwise, table lookup method is used.
POISNORM
for
λ
1, method based on Poisson inverse CDF approximation by Gaussian inverse CDF;
for
λ
< 1, table lookup method is used.
NBAR
Acceptance/rejection method for ,
Equation
with decomposition into 5 regions:
  • rectangular
  • 2 trapezoid
  • left exponential tail
  • right exponential tail
CHI2GAMMA
Random number generator of chi-square distribution with
ν
degrees of freedom. To generate any successive random number
x
of the chi-square distribution:
  • If
    ν
    is 1 or 3, a chi-square distributed random number is generated as a sum of squares of
    ν
    independent normal random numbers with mean value a = 0 and standard deviation
    σ
    =1.
  • If
    ν
    is even and 2
    ν
    16, a chi-square distributed random number is generated using the formula:
    where
    u
    i
    are successive random numbers uniformly distributed over the interval (0, 1)
  • If
    ν
    17 or
    ν
    is odd and 5
    ν
    15, a chi-square distribution is reduced to a Gamma distribution with these parameters:
    • Shape
      α
      =
      ν
      / 2
    • Offset a = 0
    • Scale factor
      β
      = 2
    The random numbers of the Gamma distribution are generated using the VSL_RNG_METHOD_GAMMA_GNORM method.
In this document, routines are often referred to by their base name (
Gaussian
) when this does not lead to ambiguity. In the routine reference, the full name (
vsrnggaussian
,
vsRngGaussian
) is always used in prototypes and code examples.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804