(May-29-2020, 05:51 AM)Gribouillis Wrote: Concerning randn()
, your output has length 100, so that there is no issue.
Yes, now I see that you're right. I must've been drunk while counting it the last night.
(May-29-2020, 05:51 AM)Gribouillis Wrote: 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).
I understand seed() method from the beginning but don't see why 42 is in parenthesis. Could it be any other number? In documentation, we have 0.