correl-z
correlated standard normal distribution Z random number generator
• Example • API • License
Example
var correlZ = require('correlZ'),
randomZ = require('random-z'),
cholesky = require('cholesky')
var correlMatrix = [[1], [0.2, 1], [0.2, 0.2, 1]]
correlWeights = cholesky(correlMatrix),
correlSeeders = correlWeights.map(correlZ)
var iids = correlWeights.map(randomZ)
var x0 = correlSeeder[0](iids),
x1 = correlSeeder[1](iids),
x2 = correlSeeder[2](iids)
API
The module exports a single function that takes an array of linear factors to be applied to shared standard normal
Independent and identically distributed random_variables
(iids) and returns a standard normal correlated random number generator.
correlZ(arrayOfLinearWeights) => randomNumberGenerator
arrayOfLinearWeights
: array linear factor for each iidrandomNumberGenerator(iids[, zSeed]) => randomNumber
iids
: array of iid valueszSeed
: optional standard normal seed for testing. Normally generated internally
Note that the linear iid weights can obtained from the correlation matrix with the
cholesky module.
License
Released under the MIT License