不支持的操作数类型'list'和'float'

时间:2015-11-19 20:22:11

标签: python python-2.7

import matplotlib.pyplot as plt

import numpy as np

from math import *

f2 = open('C:\\Users\\Audrey\\Documents\\samplestats data.txt')

lines = f2.readlines()

f2.close()

x1 = []

for line in lines:
    p = line.split()
    x1.append(float(p[0]))


#First we can find the mean
mean=(sum(x1)/len(x1))


print mean

#Next the sample variance (s^2). We use the mean which is 3.74

samplev=((sum(x1-3.74)**2)/(10-1))

print samplev

样本方差有问题,我该如何解决?

0 个答案:

没有答案