Simulation & Probabilistic Analysis SDK
Add Distribution Fitting & Simulation Features to Your Applications

SPA SDK Help HomeLearn More About the SPA SDK

Simulation

The SPA SDK allows to generate high quality random numbers from any of the supported probability distributions. The first (optional) step is to initialize the random number generator using the SPAApplication.Randomize method. The next step is to specify the distribution type and parameters using the SPADistribution object member functions.

The actual simulation can be done using two methods: SPADistribution.Random and SPADistribution.RandomArray. The former method returns only one random number at a time, while the latter one can be used to generate a large array of random numbers without having to call the method multiple times.

Random Number Generator

The SDK uses the Mersenne Twister algorithm which generates very high quality pseudorandom numbers. The generator has a period of 219937-1 (more than 106000) and passes numerous tests for statistical randomness, including the well-known Diehard tests (a number of statistical tests for measuring the quality of a set of random numbers). These qualities, along with its high speed, make the Mersenne Twister generator an algorithm of choice for most statistical simulations.

Example

The following example generates 250 random numbers from the Gamma distribution with parameters alpha=3, beta=1.5:

Sub Test()
  Dim data() As Double
  Dim dist As New SPADistribution

  SPAApplication.Initialize

  ' initialize random number generator using the current system time
  SPAApplication.Randomize

  ' specify the distribution type and parameters
  dist.Type = SPADistGamma  ' Gamma distribution 
  dist.Param(0) = 3         ' alpha
  dist.Param(1) = 1.5       ' beta

  ' perform simulation 
  Call dist.RandomArray(250, data)
End Sub
  
Copyright © MathWave Technologies
www.mathwave.com