defvariance(s):####主要是求方差的narray=numpy.array(s)sum1=narray.sum()narray2=narray*narraysum2=narray2.sum()mean=sum1/len(s)var=sum2/len(s)-mean**2printvarreturnvarianc...
def variance(s):####主要是求方差的
narray=numpy.array(s)
sum1=narray.sum()
narray2=narray*narray
sum2=narray2.sum()
mean=sum1/len(s)
var=sum2/len(s)-mean**2
print var
return variance
f1=wave.open(r'/home/yun/gqrx-20150320-085746.wav','rb')
#read the wave's format infomation,and return a tuple
params = f1.getparams()
#get the info
nchannels, sampwidth, framerate, nframes = params[:4]
#Reads and returns nframes of audio, as a string of bytes.
expectedfile = f1.readframes(nframes)
#close the stream
expected_data = np.fromstring(expectedfile, dtype = np.short)
f1.close()
variance_deviation1=variance(wave_data)####运行后,variance_deviation1就是function type,不理解为什么啊?还有怎么改回来呢?
展开