# Creating Random Stream Copy and Copying Stream State

VSL provides an option of producing an exact copy of a generated stream by calling the vslCopyStream function:

# Saving and Restoring Random Streams

Typically, to get one more correct decimal digit in Monte Carlo, you need to increase the sample by the factor of 100. That makes Monte Carlo applications computationally expensive. Some of them take days or weeks while others may take several months of computations. For such applications, saving intermediate results to a file is essential to be able to continue computation using that result in case the application is terminated intentionally or abnormally.

# Independent Streams. Leapfrogging and Block-Splitting

One of the basic requirements for random number streams is their mutual independence and lack of intercorrelation. Even if you want random number samplings to be correlated, such correlation should be controllable.

You can get independent streams using various methods. This document discusses the following methods supported by VSL:

# Abstract Basic Random Number Generators. Abstract Streams

If you want to use a BRNG not included in VSL together with VSL distribution generators, you can register your generator using the vslRegisterBrng function. In this case, your own BRNG should meet VSL BRNG interface requirements. Otherwise, you can use VSL abstract BRNGs as a wrapper.

Caution

# Generating Methods for Random Numbers of Non-Uniform Distribution

You can use a source of uniformly distributed random numbers to generate both discrete and continuous distributions, which is implemented through a number of methods briefly described below.

# Inverse Transformation

The probability distribution of a one-dimensional variate X may be most generally presented in terms of cumulative distribution function (CDF):

.

Any CDF is defined on the whole real axis and is monotonically increasing, where

# Acceptance/Rejection

The cumulative distribution functions and their inverses may often be much more complex computationally than the probability density function (for continuous distributions) and the probability mass function (for discrete distributions).

# Mixture of Distributions

You can split the initial distribution into several simpler distributions:

In this case, random numbers for each of the distributions Fi(x) are easy to generate. An appropriate algorithm may be as follows:

# Special Properties

To improve the efficiency of the algorithms based on the general methods described above, you may have to use special properties of distributions. For example, use of polar coordinates for a pair of independent normal variates enables you to develop an efficient method of random number generation based on 2D inverse transformation known as the Box-Muller method:

# Accurate and Fast Modes of Random Number Generation

Using the distribution generators in the application, you can expect the obtained random numbers to belong to definitional domain of the corresponding distribution irrespective of its parameters.