Skip to content

functions

gaussian_matrix(x, mu, sigma)

Applies gaussian function elementwise from a 'mu' and 'sigma' matrix; given a variable 'x'

Source code in slimfit/functions.py
41
42
43
44
45
46
47
48
49
50
def gaussian_matrix(x: Variable, mu: Matrix, sigma: Matrix) -> Matrix:
    """Applies gaussian function elementwise from a 'mu' and 'sigma' matrix; given a variable 'x'"""
    if mu.shape != sigma.shape:
        raise ValueError("Shape mismatch between 'mu' and 'sigma'")

    m_out = zeros(*mu.shape)
    for i, j in np.ndindex(mu.shape):
        m_out[i, j] = gaussian_sympy(x, mu[i, j], sigma[i, j])

    return m_out