-----15:18 2016/10/14-----
1.
import numpy as np;import pandas as pd
values = pd.Series(np.random.normal(0,1,size=2000))
np.random.normal(loc=mu, scale=sigma, size=Non)
标准的正态分布(mu=0,sigma=1)
np.random.normal(loc=0, scale=1, size=Non) values.hist(bins=100, alpha=0.3, color='k', normed= True)
#bins 区间数 alpha 透明度 normed=True 参数来正则化直方图
2.
cv2.error: ..\..\..\opencv-3.1.0\modules\imgproc\src\color.cpp:7456: error: (-215) scn == 3 || scn == 4 in function cv::ipp_cvtColor
主要问题就是 图片没有imread()成功。
3.
contours,hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
ValueError: too many values to unpack (expected 2)
4.Python NumPy计算欧式距离
欧式距离:在m维空间中两点的实际距离。在二维空间中,两点距离表达式:d = sqrt{(X_1 – Y_1)^2 + (X_2 – Y_2)^2}
import numpy as np #样本数据
coords1 = [1,2,3]
coords2 = [4,5,6]
np_c1 = np.array(coords1)
np_c2 = np.array(coords2) #Numpy版本
def eucldist_vectorized(coords1, coords2):
""" Calculates the euclidean distance between 2 lists of coordinates. """
return np.sqrt(np.sum((coords1 - coords2)**2)) if __name__ == "__main__":
print(eucldist_vectorized(np_c1, np_c2)) #5.19615242271