0

I am using multivariate-normal-js which is a port of NumPy's random.multivariate_normal. However, I need to be able to produce deterministic results. Is there any way do to this?

Warren Weckesser
  • 110,654
  • 19
  • 194
  • 214
Elliot
  • 1,893
  • 4
  • 17
  • 35

1 Answers1

1

multivariate-normal-js uses the inverse transform method to generate samples from a standard normal distribution, and it uses Math.random() to generate the uniformly distributed random inputs to the inverse transform. So to be able to reproduce a (pseudo-)random sequence, you would need to be able to set the random seed for Math.random(). According to the documentation for Math.random(), this is not possible.

So the short answer is no, you can't do it. But see Seeding the random number generator in Javascript and Seedable JavaScript random number generator (and maybe search for more recent discussions) if you want to try to work around that limitation of Math.random(). If you did that, you would have to replace the call to Math.random() at line 22 of distribution.js with the appropriate call of your "seedable" random number generator to generate a random value from the uniform distribution on [0, 1).

Warren Weckesser
  • 110,654
  • 19
  • 194
  • 214