# -*- coding: utf-8 -*- #1. 读入ag0613.csv数据集,并计算数据的最大值、最小值、均值、标准差、中位数 import numpy as np v=np.loadtxt('d:/pytest/ag0613.csv', delimiter=',', usecols=(0,), unpack=True) print "highest =", np.max(v) print "lowest =", np.min(v) print "avg =", np.average(v) print "std =", np.std(v) print "median =", np.median(v) #2. 矩阵计算 # (1 2 ) * (2 5) # (3 4 ) (1 3) import numpy as np x = np.array([[1, 2], [3 ,4]]) y = np.array([[2, 5], [1, 3]]) x y #矩阵相乘 x.dot(y) # 等价于np.dot(x, y) #3. 随机生成100个标准正态的数据,并计算数据的均值与标准差 import numpy as np from numpy.random import randn d=np.random.randn(100) print "avg =", np.average(d) print "std =", np.std(d)
3374 3373 3398 3419 3387 3432 3430 3449 3423 3535 3500 3501 3510 3519 3508 3522