1.numpy自帶的random函數(shù)
# coding:UTF
import numpy as np
# 構(gòu)造一個(gè)1000行丈秩,2列的array值為1~10的整數(shù)(左閉右開)
np_city = np.random.randint(1, 10, size=[1000, 2])
print np_city
[[8 5]
[9 4]
[5 6]
...
[5 6]
[3 4]
[5 9]]
2.np.mean()方法
求平均數(shù)
print np.mean(np_city[:, 0])
5.098
3.np.median()方法
求中位數(shù)
print np.median(np_city[:, 0])
5.0
4.np.corrcoef()方法
檢測相關(guān)性
print np.corrcoef(np_city[:, 0], np_city[:, 1])
[[ 1. -0.00252267]
[-0.00252267 1. ]]
5.np.std()方法
求樣本標(biāo)準(zhǔn)差
print np.std(np_city[:, 0])
2.5498792128255805