0

I am trying to port code for a generative model from python/pytorch to javascript.

To do this, I need to generate a vector of size (256,) of values sampled from a normal distribution with a seed for determinism.

In python/pytorch, I can do the following:

import torch
seed = 42
torch.manual_seed(seed)
vector = torch.randn((256))

This code ensures I get the same vector of 256 elements sampled from a normal distribution.

How can I do this in javascript?

I've seen several code examples for sampling a single value from a random normal distribution with seed. I cannot find anything for sampling a vector of random normal values with seed.

Does anyone know of a good way to do this?

Karl
  • 741
  • 4
  • 7
  • Does this answer your question? [JavaScript Math.random Normal distribution (Gaussian bell curve)?](https://stackoverflow.com/questions/25582882/javascript-math-random-normal-distribution-gaussian-bell-curve) – Epic Chen Apr 03 '22 at 06:11

0 Answers0