【发布时间】:2015-01-01 21:11:44
【问题描述】:
我正在尝试对此数据集进行平滑处理,并生成一条带有误差线的具有代表性的曲线。获取数据点的方法以相当粗略的步骤离散化。我没有太多的编程经验,但正在努力学习。我读到高斯滤波器可能是一个不错的选择。任何帮助,将不胜感激。
这是一个示例数据集:
Time (min) Non-Normalized Shrinkage Normalized Shrinkage
200 93 1.021978022
202 92 1.010989011
204 92 1.010989011
206 92 1.010989011
208 92 1.010989011
210 92 1.010989011
212 91 1
214 90 0.989010989
216 90 0.989010989
218 90 0.989010989
220 88 0.967032967
222 88 0.967032967
224 87 0.956043956
226 86 0.945054945
228 86 0.945054945
230 86 0.945054945
232 86 0.945054945
234 86 0.945054945
236 85 0.934065934
238 84 0.923076923
240 83 0.912087912
242 83 0.912087912
244 83 0.912087912
246 82 0.901098901
248 83 0.912087912
250 82 0.901098901
252 81 0.89010989
254 81 0.89010989
256 82 0.901098901
258 82 0.901098901
260 79 0.868131868
262 80 0.879120879
264 80 0.879120879
我在网上某处找到了这段代码 sn-p,但我不知道如何实现它,也不知道它是否是我正在寻找的。p>
def smoothListGaussian(list,degree=5):
window=degree*2-1
weight=numpy.array([1.0]*window)
weightGauss=[]
for i in range(window):
i=i-degree+1
frac=i/float(window)
gauss=1/(numpy.exp((4*(frac))**2))
weightGauss.append(gauss)
weight=numpy.array(weightGauss)*weight
smoothed=[0.0]*(len(list)-window)
for i in range(len(smoothed)):
smoothed[i]=sum(numpy.array(list[i:i+window])*weight)/sum(weight)
return smoothed
【问题讨论】:
标签: python numpy scipy curve-fitting smoothing