Implementation of MRG31k3p random number generator for Theano
Generator code in SSJ package (L’Ecuyer & Simard) http://www.iro.umontreal.ca/~simardr/ssj/indexe.html
Efficient and numerically stable implementation of a dot product followed by a modulo operation. This performs the same function as matVecModM.
We do this 2 times on 2 triple inputs and concatenating the output
Module component with similar interface to numpy.random (numpy.random.RandomState)
Initialize a matrix in which each row is a MRG stream state, and they are spaced by 2**72 samples.
Update self.rstate to be skipped 2^134 steps forward to the next stream start
Sample n (currently n needs to be 1) times from a multinomial distribution defined by probabilities pvals.
Example : pvals = [[.98, .01, .01], [.01, .98, .01]] will probably result in [[1,0,0],[0,1,0]].
Note
-size and ndim are only there keep the same signature as other uniform, binomial, normal, etc. todo : adapt multinomial to take that into account
Parameters: |
|
---|
Sample a tensor of given size whose element from a uniform distribution between low and high.
If the size argument is ambiguous on the number of dimensions, ndim may be a plain integer to supplement the missing information.
Parameters: |
|
---|
Return a guess at a good number of streams.
Parameters: | warn – If True, warn when a guess cannot be made (in which case we return 60 * 256). |
---|
multiply the first half of v by A with a modulo of m1 and the second half by B with a modulo of m2
Note: The parameters of dot_modulo are passed implicitly because passing them explicitly takes more time then running the function’s C-code.