计算得出0-299这300个数的线性插值
def interpNumList(num):
"""
计算线性插值列表
:param NumList:
:return:
"""
interpList = []
NumList = [i for i in range(num + 1)]
startList = [0.2, 0.4, 0.6, 0.8]
interpList.extend(startList)
startListCopy = startList.copy()
for i in range(len(NumList)):
start = i
mid = start + 1
end = start + 2
if end <= len(NumList) - 1:
x1 = np.array([NumList[start], NumList[mid]])
y1 = np.array([NumList[mid], NumList[end]])
res = list(np.interp(startListCopy, x1, y1))
interpList.extend(res)
startListCopy = res
else:
break
resultList = sorted(interpList + NumList[:-1], reverse=False)
return resultList
ok, 300个数字线性插值完成!