Created
February 15, 2019 15:38
-
-
Save Robofied/94714e81c6aae3a841c34f94cd81dd30 to your computer and use it in GitHub Desktop.
Numpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y= a.mean(axis=1) | |
print(y) | |
#[Output]: | |
#[0.5 2.5 4.5] | |
y.reshape(3,1) | |
#[Output]: | |
#array([[0.5], | |
# [2.5], | |
# [4.5]]) | |
print(a-y.reshape(3,1)) | |
#[Output]: | |
#[[-0.5 0.5] | |
# [-0.5 0.5] | |
# [-0.5 0.5]] | |
z = np.sum(np.square(a-y.reshape(3,1)),axis=1) | |
print(z) | |
#[Output]: | |
#[0.5 0.5 0.5] | |
print(z/a.shape[1]) | |
#[Output]: | |
#array([0.25, 0.25, 0.25]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment