18. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element?
print(np.unravel_index(100,(6,7,8))) #看不懂是什么意思
20. Normalize a 5x5 random matrix (★☆☆)Z = np.random.random((5,5))
Zmax, Zmin = Z.max(), Z.min()
Z = (Z - Zmin)/(Zmax - Zmin) # 为什么这样可以归一化矩阵
print(Z)
24. What is the output of the following script? (★☆☆)# Author: Jake VanderPlas
print(sum(range(5),-1))
from numpy import *
print(sum(range(5),-1)) # 为什么不同呀...
25. Consider an integer vector Z, which of these expressions are legal? (★☆☆)2 <> 2 # 这是在干嘛...
Z
Z/1/1
ZZ #不懂+1
BTW..
>>> z = array([0,1])
>>> z**z
array([1, 1])
>>> 2<>2
array([0, 1])
>>> z
array([False, False], dtype=bool)
>>> 1j*z
array([ 0.+0.j, 0.+1.j])
>>> z/1/1
array([0, 1])
>>> zz
Traceback (most recent call last):
File "", line 1, in
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
39. Given two arrays, X and Y, construct the Cauchy matrix C (Cij = 1/(xi - yj))# Author: Evgeni Burovski
X = np.arange(8)
Y = X + 0.5
C = 1.0 / np.subtract.outer(X, Y) #为什么是subtract.outer,substract是减法,outer是乘法....然后做逆做行列式就更不懂了QAQ
print(np.linalg.det(C))