In [8]:
%matplotlib inline
In [9]:
#http://stackoverflow.com/questions/19215335/finding-the-intersection-of-a-curve-from-polyfit
In [33]:
from __future__ import division
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
w = np.array([0.0, 11.11111111111111, 22.22222222222222, 33.333333333333336,
44.44444444444444, 55.55555555555556, 66.66666666666667,
77.77777777777777, 88.88888888888889, 100.0])
v = np.array([0.0, 8.333333333333332, 16.666666666666664, 25.0,
36.11111111111111, 47.22222222222222, 27.333333333333336,
16.22222222222221, 2.11111111111111, 00.0])
poly_coeff = np.polynomial.polynomial.polyfit(w, v, 2)
poly = np.polynomial.polynomial.Polynomial(poly_coeff)
print poly
roots = np.polynomial.polynomial.polyroots(poly_coeff)
print roots
#x = np.linspace(np.min(roots) - 50, np.max(roots) + 50, num=1000)
plt.plot(w, v, 'b-')
plt.plot(w, poly(w), 'r-')
#plt.plot(w, 99 - x, 'b-')
for root in roots:
plt.plot(root, 'ro')
In [ ]: