Gaussian#
lamatrix
provides a Gaussain model which can be used to capture normal distributions.
[8]:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-10, 10, 0.01)
from lamatrix import Gaussian
[9]:
Gaussian().equation
[9]:
\[f(\mathbf{x}) = w_{0} \frac{1}{\sqrt{2\pi\sigma^2}} e^{-\frac{\mathbf{x} - \mu^2}{2\sigma^2}}\]
[10]:
model = Gaussian('x', sigma=2, mu=1)
w = np.random.uniform(0, 1, 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='Gaussian model sample');
