Polynomial#

lamatrix provides a Polynomial model which can be used to capture simple trends.

[1]:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-10, 10, 0.01)


from lamatrix import Polynomial
[3]:
Polynomial(order=3).equation
[3]:
\[f(\mathbf{x}) = w_{0} \mathbf{x}^{1} + w_{1} \mathbf{x}^{2} + w_{2} \mathbf{x}^{3}\]
[10]:
model = Polynomial('x', order=3)
w = np.random.normal(size=model.width)
sample = model.design_matrix(x=x).dot(w)
[11]:
fig, ax = plt.subplots()
ax.plot(x, sample, c='k')
ax.set(xlabel='$x$', ylabel='$y$', title='Polynomial model sample');
../_images/model-examples_Polynomial_5_0.png