2014-10-04 84 views
-2

我有两个列表。我想插入两个列表中的每个元素之间。两个列表中的值之间的插值

Interpolation_greater_values = [2.7577, 147.1441, 292.4872, 512.2606, 840.8513, 1335.3837, 1462.9142] 
Interpolation_small_values = [0.0000, 145.9340, 291.3053, 511.1912, 839.7539, 1333.8079, 1461.3383] 

例如,我想插入2.75770.0000,147.1441145.9340之间,等等。我怎样才能做到这一点?

+0

SciPy的和numpy的必须使用这个很好的工具:http://docs.scipy.org/doc/scipy-0.14.0/reference/tutorial/interpolate.html – tom10 2014-10-04 14:45:01

+0

当你说“插值” ,那么你的意思是“我想在两个列表中的元素之间取两两平均数”,不是吗? – kay 2014-10-04 14:48:41

回答

1
l1 = [2.7577, 147.1441, 292.4872, 512.2606, 840.8513, 1335.3837, 1462.9142] 
l2 = [0.0000, 145.9340, 291.3053, 511.1912, 839.7539, 1333.8079, 1461.3383] 

interp = [(i1 + i2)/2.0 for i1, i2 in zip(l1, l2)] 

>>> interp 
[1.37885, 146.53905, 291.89625, 511.72589999999997, 840.3026, 1334.5958, 1462.1262499999998] 
+0

非常感谢您的回答。 – 2014-10-04 14:48:38

+0

@AmeyaKulkarni:如果这回答你的问题,请接受它(点击左边的复选标记)。 – tom10 2014-10-04 15:16:06