May-29-2020, 05:51 AM
(This post was last modified: May-29-2020, 05:51 AM by Gribouillis.)
Concerning
Concerning
randn()
, your output has length 100, so that there is no issue.Concerning
seed()
, the purpose of such functions is to generate repeatable pseudo random sequences, for example>>> np.random.seed(42) >>> np.random.randn(5) array([ 0.49671415, -0.1382643 , 0.64768854, 1.52302986, -0.23415337]) >>> np.random.seed(42) # restart the generator with the same seed >>> np.random.randn(5) array([ 0.49671415, -0.1382643 , 0.64768854, 1.52302986, -0.23415337]) # same random sequence >>> np.random.seed(3748867) # a different seed >>> np.random.randn(5) array([-1.87666266, 2.5862967 , -0.49532264, -0.01653639, 0.01915029]) # a different random sequence >>>That said, numpy's documentation describes seed() as a convenience, legacy function. It means that one shouldn't call it but probably use RandomState instances instead, which also have seed() and randn() methods (be cautious however as RandomState is also described as a legacy class in other parts of the documentation, seeding seems to be a tricky subject. As an average user, one can perhaps avoid the details).