-
Notifications
You must be signed in to change notification settings - Fork 73
Random number generators
Calling rand(m:Int, n:Int):FMat returns an m x n FMat of random numbers uniformly distributed between 0 and 1.
Calling rand(m:Int, n:Int, a:Double, b:Double):FMat returns an m x n FMat of uniformly distributed random numbers between a and b.
Calling rand(M:FMat) with an FMat argument M fills M with uniform random numbers in [0,1].
Calling rand(M:FMat, a:Double, b:Double) with a FMat argument M fills M with uniform random numbers in [a,b].
Calling sprand(m:Int, n:Int, p:Double):SMat creates an SMat with density p. That is, p is the probability that any particular element occurs (is nonzero) in the matrix. The values of non-zeros are uniform in the interval [0,1].
Calling normrnd(mu:Double, sigma:Double, m:Int, n:Int):FMat generates an m x n FMat of normally-distributed random numbers with mean mu, and standard deviation sigma. Calling normrnd(mu:Double, sigma:Double, M:FMat) for FMat M returns the results in M.
Calling gamrnd(shape:Double, scale:Double, m:Int, n:Int):FMat generates an m x n FMat of gamma-distributed random numbers with appropriate shape and scale. Calling gamrnd(shape:Double, scale:Double, M:FMat) for FMat M returns the results in M.
Calling laprnd(mu:Double, b:Double, m:Int, n:Int):FMat generates an m x n FMat of Laplace-distributed random numbers with mean mu, and variance 2b^2. Calling laprnd(mu:Double, b:Double, M:FMat) for FMat M returns the results in M.
Calling cauchyrnd(a:Double, b:Double, m:Int, n:Int):FMat generates an m x n FMat of Cauchy-distributed random numbers with location parameter a, and scale parameter b. Calling cauchyrnd(a:Double, b:Double, M:FMat) for FMat M returns the results in M.
Calling exprnd(a:Double, b:Double, m:Int, n:Int):FMat generates an m x n FMat of Exponentially-distributed random numbers with displacement a and scale b. Calling exprnd(a:Double, b:Double, M:FMat) for FMat M returns the results in M.
Calling betarnd(p:Double, q:Double, a:Double, b:Double, m:Int, n:Int):FMat generates an m x n FMat of Beta-distributed random numbers with distribution probabilities p and q, displacement a, and scale parameter b. Calling betarnd(p:Double, q:Double, a:Double, b:Double, M:FMat) for FMat M returns the results in M.
Calling binornd(k:Int, p:Double, m:Int, n:Int):IMat generates an m x n IMat of Binomially-distributed random numbers representing k trials of an event with probability p. Calling binornd(k:Int, p:Double, M:IMat) for IMat M returns the results in M.
Calling bernrnd(p:Double, m:Int, n:Int):IMat generates an m x n IMat of Bernoulli-distributed random numbers representing single trials with probability p. The output matrix will be 0-1 valued. Calling bernrnd(p:Double, M:IMat) for IMat M returns the results in M.
Calling geornd(p:Double, m:Int, n:Int):IMat generates an m x n IMat of Geometrically-distributed random numbers representing chains of trials with probability p. Calling geornd(p:Double, M:IMat) for IMat M returns the results in M.
Calling nbinrnd(a:Double, p:Double, m:Int, n:Int):IMat generates an m x n IMat of Negative-Binomially-distributed random numbers with parameters a and p. Calling nbinrnd(a:Double, p:Double, M:IMat) for IMat M returns the results in M.
The poisson random number generator has two forms:
- Calling poissrnd(lambda:Double, m:Int, n:Int):IMat generates an m x n IMat of Poisson-distributed random numbers with rate lambda. Calling poissrnd(lambda:Double, M:IMat) for IMat M returns the results in M.
- Calling poissrnd(lambda:DMat, m:Int, n:Int):IMat with a DMat lambda whos dimension matches the output generates generates Poisson random numbers with individually-set rate parameter. Calling poissrnd(lambda:DMat, M:IMat) for IMat M returns the results in M.