w1_practice_01



In [2]:
import numpy as np

In [4]:
X = np.random.normal(scale=10, loc=1, size=(1000, 50))
print(X)


[[ 10.47930542  14.39930873   7.15434968 ...   7.51285104   8.26432587
   -1.19519979]
 [ 12.04992208 -13.41271892  -7.92823645 ...   3.06730829   5.36868441
    8.34432575]
 [  1.48830008  -0.34488731  -2.12110522 ...  -7.52728515  18.08180954
  -14.75416817]
 ...
 [  7.46334204 -17.21329097   7.26920327 ...   8.35224741 -20.7384274
   -5.24926013]
 [  3.20676164  -3.03023157 -18.66349648 ...  -6.83626049   7.57175262
   -1.21663889]
 [-25.02940361   4.73203729   8.77370458 ...  -0.72326104  20.69420221
    6.29501143]]

In [11]:
average = X.mean()
std = X.std()
print("Average {}".format(average))
print("Std {}".format(std))

X_norm = (X - average) / std
print(X_norm)


Average 1.56319401867e-17
Std 1.0
[[ 0.94395592  1.33580656  0.61158732 ...  0.64742376  0.72254255
  -0.22304878]
 [ 1.10095761 -1.44433414 -0.89609533 ...  0.20303925  0.43308898
   0.73053948]
 [ 0.04519873 -0.13805001 -0.31560397 ... -0.85601551  1.70391601
  -1.57842784]
 ...
 [ 0.64247475 -1.82424621  0.62306829 ...  0.73133135 -2.17662524
  -0.6283    ]
 [ 0.21697926 -0.40648189 -1.96921138 ... -0.78693944  0.65331167
  -0.22519187]
 [-2.605559    0.36944858  0.77346097 ... -0.17587293  1.96505552
   0.52568631]]

In [26]:
Z = np.array([[4, 5, 0], 
             [1, 9, 3],              
             [5, 1, 1],
             [3, 3, 3], 
             [9, 9, 9], 
             [4, 7, 1]])
lines = np.sum(Z, axis=1);
print(np.nonzero(lines > 10))


(array([1, 4, 5]),)

In [38]:
matrix1 = np.eye(3)
matrix2 = np.eye(3)

print(np.concatenate((matrix1, matrix2), axis=0))
print("\n")
print(np.vstack((matrix1, matrix2)))


[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]
 [1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]


[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]
 [1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]

In [ ]: