Initializing a dynamically sized Matrix randomly

help

#1

Hi!

I’ve just started looking at the library, and have a question. I want to generate a matrix of some size (not known at compile time) of floats, and I want the floats to be randomly sampled from a standard normal distribution. I can basically see how to do the initialization manually in steps, but this seems really similar to new_random (and maybe new_random_generic (whose implementation I didn’t really understand).

Is thee any way I can use builtin library functions to consisely do what I’m trying to?

Thanks!


#2

Hi!

Sorry for the late answer. I’ve made this pull request that will allow you to create a random matrix with a user-defined distribution: DMatrix::from_distribution(nrows, ncols, distribution, rng). I will merge and release it as soon as the CI succeeds.