Fitting in Chebyshev basisΒΆ

Plot noisy data and their polynomial fit in a Chebyshev basis

import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-1, 1, 2000)
y = np.cos(x) + 0.3*np.random.rand(2000)
p =, y, 90)
plt.plot(x, y, 'r.')
plt.plot(x, p(x), 'k-', lw=3)

Total running time of the script: ( 0 minutes 0.020 seconds)

Gallery generated by Sphinx-Gallery