如何使用Python测量Numpy数据与模式/模型/函数之间的近似匹配?
我有一些数据点(x和y),我想检查以下哪个模型与数据点匹配:
y = x^2
y = -x^2 < /code>
y = 0
我想考虑一个大小35的窗口,然后移动窗口,并在每个步骤中验证数据点与上述模型的主管匹配。
换句话说,我打算发现每个数据点是否最有可能继续直线。否则数据点将继续增加趋势曲线(这是一条最小后面的曲线);或者它将继续降低趋势曲线(这是一条最大后面的曲线)。
y = np.array([[1.6396475],
[1.6396625],
[1.639665 ],
[1.6395325],
[1.6396125],
[1.6394225],
[1.6389825],
[1.6388175],
[1.63901 ],
[1.6389325],
[1.63897 ],
[1.638955 ],
[1.638855 ],
[1.638905 ],
[1.639 ],
[1.639305 ],
[1.6393875],
[1.6393675],
[1.63916 ],
[1.63879 ],
[1.638545 ],
[1.6384525],
[1.638495 ],
[1.6385625],
[1.6383125],
[1.6382875],
[1.6384075],
[1.6382775],
[1.6382975],
[1.6383525],
[1.6387725],
[1.639285 ],
[1.6397525],
[1.6400825],
[1.6403925],
[1.64065 ],
[1.641025 ],
[1.6409375],
[1.6407275],
[1.64112 ],
[1.6416275],
[1.641705 ],
[1.6419825],
[1.642025 ],
[1.641535 ],
[1.6412825],
[1.641395 ],
[1.6413375],
[1.641145 ],
[1.6411725],
[1.6412975],
[1.641525 ],
[1.641715 ],
[1.6416025],
[1.64136 ],
[1.640975 ],
[1.6402425],
[1.64007 ],
[1.640575 ],
[1.6408675],
[1.6407075],
[1.6403825],
[1.6402525],
[1.64014 ],
[1.6400675],
[1.6397975],
[1.639635 ],
[1.63979 ],
[1.6397275],
[1.639685 ],
[1.63938 ],
[1.6392375],
[1.63906 ],
[1.6387775],
[1.638465 ],
[1.638495 ],
[1.6387 ],
[1.6384675],
[1.6382575],
[1.63833 ],
[1.6382725],
[1.63815 ],
[1.6381175],
[1.63801 ],
[1.637945 ],
[1.637915 ],
[1.637885 ],
[1.6381025],
[1.638095 ],
[1.637975 ],
[1.6378325],
[1.637945 ],
[1.6382925],
[1.63824 ],
[1.63781 ],
[1.6375275],
[1.6375875],
[1.63764 ],
[1.637715 ],
[1.637785 ]])
x = np.array([[ 0.],
[ 1.],
[ 2.],
[ 3.],
[ 4.],
[ 5.],
[ 6.],
[ 7.],
[ 8.],
[ 9.],
[10.],
[11.],
[12.],
[13.],
[14.],
[15.],
[16.],
[17.],
[18.],
[19.],
[20.],
[21.],
[22.],
[23.],
[24.],
[25.],
[26.],
[27.],
[28.],
[29.],
[30.],
[31.],
[32.],
[33.],
[34.],
[35.],
[36.],
[37.],
[38.],
[39.],
[40.],
[41.],
[42.],
[43.],
[44.],
[45.],
[46.],
[47.],
[48.],
[49.],
[50.],
[51.],
[52.],
[53.],
[54.],
[55.],
[56.],
[57.],
[58.],
[59.],
[60.],
[61.],
[62.],
[63.],
[64.],
[65.],
[66.],
[67.],
[68.],
[69.],
[70.],
[71.],
[72.],
[73.],
[74.],
[75.],
[76.],
[77.],
[78.],
[79.],
[80.],
[81.],
[82.],
[83.],
[84.],
[85.],
[86.],
[87.],
[88.],
[89.],
[90.],
[91.],
[92.],
[93.],
[94.],
[95.],
[96.],
[97.],
[98.],
[99.]])
I have some data points (x and y) and I want to check which of the following models matches the best with the data points:
y = x^2
y = -x^2
y = 0
I want to consider a window of size 35, and move the window, and verify in each step the data points are matching with which of the HEAD of above-mentioned models.
In other words, I intend to discover if each data point is most likely to continue a straight line; or the data point is going to continue an increasing-trend curve (it is a curve with minimum behind); or it is going to continue a decreasing-trend curve (it is a curve with maximum behind).
y = np.array([[1.6396475],
[1.6396625],
[1.639665 ],
[1.6395325],
[1.6396125],
[1.6394225],
[1.6389825],
[1.6388175],
[1.63901 ],
[1.6389325],
[1.63897 ],
[1.638955 ],
[1.638855 ],
[1.638905 ],
[1.639 ],
[1.639305 ],
[1.6393875],
[1.6393675],
[1.63916 ],
[1.63879 ],
[1.638545 ],
[1.6384525],
[1.638495 ],
[1.6385625],
[1.6383125],
[1.6382875],
[1.6384075],
[1.6382775],
[1.6382975],
[1.6383525],
[1.6387725],
[1.639285 ],
[1.6397525],
[1.6400825],
[1.6403925],
[1.64065 ],
[1.641025 ],
[1.6409375],
[1.6407275],
[1.64112 ],
[1.6416275],
[1.641705 ],
[1.6419825],
[1.642025 ],
[1.641535 ],
[1.6412825],
[1.641395 ],
[1.6413375],
[1.641145 ],
[1.6411725],
[1.6412975],
[1.641525 ],
[1.641715 ],
[1.6416025],
[1.64136 ],
[1.640975 ],
[1.6402425],
[1.64007 ],
[1.640575 ],
[1.6408675],
[1.6407075],
[1.6403825],
[1.6402525],
[1.64014 ],
[1.6400675],
[1.6397975],
[1.639635 ],
[1.63979 ],
[1.6397275],
[1.639685 ],
[1.63938 ],
[1.6392375],
[1.63906 ],
[1.6387775],
[1.638465 ],
[1.638495 ],
[1.6387 ],
[1.6384675],
[1.6382575],
[1.63833 ],
[1.6382725],
[1.63815 ],
[1.6381175],
[1.63801 ],
[1.637945 ],
[1.637915 ],
[1.637885 ],
[1.6381025],
[1.638095 ],
[1.637975 ],
[1.6378325],
[1.637945 ],
[1.6382925],
[1.63824 ],
[1.63781 ],
[1.6375275],
[1.6375875],
[1.63764 ],
[1.637715 ],
[1.637785 ]])
x = np.array([[ 0.],
[ 1.],
[ 2.],
[ 3.],
[ 4.],
[ 5.],
[ 6.],
[ 7.],
[ 8.],
[ 9.],
[10.],
[11.],
[12.],
[13.],
[14.],
[15.],
[16.],
[17.],
[18.],
[19.],
[20.],
[21.],
[22.],
[23.],
[24.],
[25.],
[26.],
[27.],
[28.],
[29.],
[30.],
[31.],
[32.],
[33.],
[34.],
[35.],
[36.],
[37.],
[38.],
[39.],
[40.],
[41.],
[42.],
[43.],
[44.],
[45.],
[46.],
[47.],
[48.],
[49.],
[50.],
[51.],
[52.],
[53.],
[54.],
[55.],
[56.],
[57.],
[58.],
[59.],
[60.],
[61.],
[62.],
[63.],
[64.],
[65.],
[66.],
[67.],
[68.],
[69.],
[70.],
[71.],
[72.],
[73.],
[74.],
[75.],
[76.],
[77.],
[78.],
[79.],
[80.],
[81.],
[82.],
[83.],
[84.],
[85.],
[86.],
[87.],
[88.],
[89.],
[90.],
[91.],
[92.],
[93.],
[94.],
[95.],
[96.],
[97.],
[98.],
[99.]])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,这是一个长期的问题。我希望其他人可以提供更好的答案。
在这里,我提到一个答案,然后在我附上最终答案的图像之前:
It was a long-time this was a question in my mind. And I hope that others can provide better answers.
Here, I am mentioning an answer, before I am attaching the image of the final answer: