赞
踩
如果我有一个由50个元素组成的数组,我将如何计算3个周期的斜率和5个周期的斜率?
医生们没有增加太多。。。。。>>> from scipy import stats
>>> import numpy as np
>>> x = np.random.random(10)
>>> y = np.random.random(10)
>>> slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
这行吗?def slope(x, n):
if i
slope = stats.linregress(x[i:i+n],y[i:i+n])[0]
return slope
但是数组的长度是否相同
@乔:::xx = [2.0 ,4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]
x = np.asarray(xx, np.float)
s = np.diff(x[::3])/3
window = [1, 0, 0, 0, -1]
window2 = [1, 0, -1]
slope = np.convolve(x, window, mode='same') / (len(window) - 1)
slope2 = np.convolve(x, window2, mode='same') / (len(window2) - 1)
prin
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。