# Random Number Generators

VSL provides a set of routines implementing commonly used pseudo- or quasi-random number generators with continuous and discrete distribution. To speed up performance, all these routines were developed using the calls to the highly optimized Basic Random Number Generators (BRNGs) and the library of vector mathematical functions (VML, see “Vector Mathematical Functions”).

VSL provides interfaces both for FORTRAN and C languages. For users of the C and C++ languages the mkl_vsl.h header file is provided. For users of the Fortran 90 or Fortran 95 language the mkl_vsl.fi header file is provided. Both header files are found in the following directory:

`${MKL}/include`

The mkl_vsl.fi header is intended for using via the FORTRAN `include` clause and is compatible with both standard forms of F90/F95 sources — the free and 72-columns fixed forms. If you need to use the VSL interface with 80- or 132-columns fixed form sources, you may add a new file to your project. That file is formatted as a 72-columns fixed-form source and consists of a single `include` clause as follows:

`include ‘mkl_vsl.fi’`

This `include` clause causes the compiler to generate the module files mkl_vsl.mod and mkl_vsl_type.mod, which are used to process the FORTRAN use clauses referencing to the VSL interface:

`use mkl_vsl_type`
`use mkl_vsl`

Because of this specific feature, you do not need to include the mkl_vsl.fi header into each source of your project. You only need to include the header into some of the sources. In any case, make sure that the sources that depend on the VSL interface are compiled after those that include the header so that the module files mkl_vsl.mod and mkl_vsl_type.mod are generated prior to using them.

### Note

For FORTRAN interface, VSL provides both subroutine-style interface and function-style interface. Default interface in this case is a function-style interface. Subroutine-style interface is provided for backward compatibility only. To use subroutine-style interface, manually include mkl_vsl_subroutine.fi file instead of mkl_vsl.fi by changing the line `include ‘mkl_vsl.fi’` in include\mkl.fi with the line `include ‘mkl_vsl_subroutine.fi’`.

Function-style interface, unlike subroutine-style interface, allows user to get error status of each routine.

All VSL routines can be classified into three major categories:

- Transformation routines for different types of statistical distributions, for example, uniform, normal (Gaussian), binomial, etc. These routines indirectly call basic random number generators, which are either pseudorandom number generators or quasi-random number generators. Detailed description of the generators can be found in Distribution Generators.

- Service routines to handle random number streams: create, initialize, delete, copy, save to a binary file, load from a binary file, get the index of a basic generator. The description of these routines can be found in Service Subroutines.

- Registration routines for basic pseudorandom generators and routines that obtain properties of the registered generators (see Advanced Service Subroutines).

The last two categories are referred to as service routines.

- Conventions
- Basic Generators
- Error Reporting
- Service Routines
- Distribution Generators
- Advanced Service Routines

Parent topic: Statistical Functions