mardi 2 juin 2020

Set output matrix on numpy binomial function

I want to use the following example in my project, which fills an array with random values, using multiple threads. https://numpy.org/doc/1.18/reference/random/multithreading.html.

However, instead of the standard normal distribution I want to use a binomial distribution. My problem is that the method numpy.random.Generator.binomial does not have an "out" argument (like the standard_normal method) where the result will be placed. This means that I will have to copy the output matrix given to me to my matrix, heavily decreasing performance.

Is there an alternative library/approach that will solve this issue?

If this helps, I actually need the Bernoulli distribution, i.e. n=1 in the binomial distribution (but an arbitrary p).




Aucun commentaire:

Enregistrer un commentaire