import numpy as np
sample = np.random.random((3,2))
print(sample)
print(type(sample))
out:
[[0.60438951 0.34667702]
[0.18884105 0.51541119]
[0.03031478 0.34442602]]
out:
<class 'numpy.ndarray'>
sample2 = np.random.normal(size=(3,2))
print(sample2)
out:
[[ 0.21854734 -0.47909311]
[ 0.79658506 0.95975048]
[-1.69823131 -1.13637119]]
sample3 = np.random.randint(0,10,size=(3,2))
print(sample3)
out:
[[3 2]
[8 6]
[7 9]]
np.sum(sample)
out:3.075403867825465
np.min(sample)
out:0.035139839607487344
np.max(sample)
out:0.9874316838109113
np.sum(sample,axis=0)
out:array([1.89813692, 1.17726695])
np.sum(sample,axis=1)
out:array([1.47406106, 0.44446049, 1.15688231])
print(sample)
out:
[[0.8755654 0.59849567]
[0.03513984 0.40932065]
[0.98743168 0.16945063]]
np.argmin(sample)
out:2
np.argmax(sample)
out:4
print(sample.mean())
print(np.mean(sample))
out:0.5125673113042442
np.median(sample)
out:0.5039081597664679
np.sqrt(sample)
out:
array([[0.93571651, 0.77362502],
[0.18745623, 0.63978172],
[0.99369597, 0.41164381]])
sample4 = np.random.randint(0,10,size=(1,10))
print(sample4)
out:
[[0 7 6 0 2 8 1 2 2 4]]
np.sort(sample4)
out:
array([[0, 0, 1, 2, 2, 2, 4, 6, 7, 8]])
np.sort(sample3)
out:
array([[2, 3],
[6, 8],
[7, 9]])
np.clip(sample4,2,7)
out:
array([[2, 7, 6, 2, 2, 7, 2, 2, 2, 4]])