<p>可以在多项式搜索中添加次。尝试4而不是3例如,它不会超过100</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from numpy.polynomial import Polynomial as P
points = np.array([(0, 0), (3, 0), (7, 55), (14, 88)])
x = points[:,0]
y = points[:,1]
y_fit = P.fit(x, y, 4)
x_new = np.linspace(x[0], x[-1], 50)
plt.plot(x,y,'o', x_new, y_fit(x_new))
plt.xlim([x[0]-1, x[-1] + 1 ])
plt.axhline(100)
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/eDela.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eDela.png" alt="enter image description here"/></a></p>
<p>如果你真的想试着用四阶近似计算它何时达到100:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from numpy.polynomial import Polynomial as P
points = np.array([(0, 0), (3, 0), (7, 55), (14, 88)])
# get x and y vectors
x = points[:,0]
y = points[:,1]
y_fit = P.fit(x, y, 4)
x_new = np.linspace(0, 20, 100)
plt.plot(x,y,'o', x_new, y_fit(x_new))
plt.axhline(100)
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/7ayRa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7ayRa.png" alt="enter image description here"/></a></p>
<p>但是没有什么能保证这一趋势的真实性,因为它也可以用任何其他次序或任何其他函数来近似</p>