mercredi 18 novembre 2020

Meaning of "2 * np.random.rand(100,1)"

I'm a begginer on programming.
I tried running an simple linear regression example in a book. Y=4*X+6
I have set np.random.seed(0).
When creating X, the code in the book used 2 * np.random.rand(100,1).
I created X1, X2, X3 in the following way. Below is the code.

import numpy as np

np.random.seed(0)  
X1 = 2 * np.random.rand(5,1)  
X2 = np.random.rand(5,1)  
X3 = 2 * X2  
print('X1= ', X1)  
print('X2= ', X2)  
print('X3= ', X3)  

I have questions here.

  1. What is the meaning of multiply 2 with np.random.rand(100,1)? As a result of running the above code, it seems that it is not simply doubling the value or doubling the size.
  2. And why the results of X1 and X3 are different?



Aucun commentaire:

Enregistrer un commentaire