lundi 10 octobre 2022

How do I "fix" a randomly generated value on Pyhton? [duplicate]

I'm on Python and have generated a numpy.ndarray in the following manner:

import numpy as np
from numpy import * #para importar además todas las cosas dentro de numpy, opcional
from scipy.stats import cauchy

x=cauchy.rvs(loc=0, scale=1, size=3360000)

I want to make different calculations with x but, in order to do this, x must remain constant independent of how many times I run the code (I don't want x to get redefined every time I run my code). To give a more clear idea of what I want, if instead of 3 360 000 Cauchy samples, I had only 3 (say, x=[1,2,3]) then I would run it once and then type x=[1,2,3] at the beginning of the code (replacing the first piece of code mentioned in my question). The sample size being so big makes this imposible.

How do I fix a randomly generated element on python?

btw, I have very little experience when it comes to programming and it´s definitely not my strongest asset.




Aucun commentaire:

Enregistrer un commentaire