In [1]: import numpy as np
In [2]: np.arange(10)
Out[2]: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
In [3]: np.arange(1, 11)
Out[3]: array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
In [4]: np.arange(1, 11, 2)
Out[4]: array([1, 3, 5, 7, 9])
In [5]: f = np.random.random((3,2))
In [6]: f
Out[6]:
array([[0.42878081, 0.59925055],
[0.68555657, 0.82703065],
[0.37546279, 0.70540254]])
In [7]: np.random.seed(123)
In [8]: np.random.random((3,2))
Out[8]:
array([[0.69646919, 0.28613933],
[0.22685145, 0.55131477],
[0.71946897, 0.42310646]])
In [9]: np.random.seed(123)
In [10]: np.random.rand(4,2)
Out[10]:
array([[0.69646919, 0.28613933],
[0.22685145, 0.55131477],
[0.71946897, 0.42310646],
[0.9807642 , 0.68482974]])
In [11]: np.random.seed(123)
In [12]: np.random.randit(1,10)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-2fe17f51d599> in <module>
----> 1 np.random.randit(1,10)
AttributeError: module 'numpy.random' has no attribute 'randit'
In [13]: np.random.randint(1,10)
Out[13]: 3
In [14]: np.random.seed(123)
In [15]: np.random.randint(1,10,(3,3))
Out[15]:
array([[3, 3, 7],
[2, 4, 7],
[2, 1, 2]])
In [16]: np.random.seed(123)
I
n [17]: np.random.uniform(0.0, 5.0, size=(2,3))
Out[17]:
array([[3.48234593, 1.43069667, 1.13425727],
[2.75657385, 3.59734485, 2.1155323 ]])
In [18]: np.random.seed(123)
In [19]: np.random.uniform(size=(4,3))
Out[19]:
array([[0.69646919, 0.28613933, 0.22685145],
[0.55131477, 0.71946897, 0.42310646],
[0.9807642 , 0.68482974, 0.4809319 ],
[0.39211752, 0.34317802, 0.72904971]])
In [20]: np.random.seed(123)
In [21]: np.random.randn(4,2)
Out[21]:
array([[-1.0856306 , 0.99734545],
[ 0.2829785 , -1.50629471],
[-0.57860025, 1.65143654],
[-2.42667924, -0.42891263]])