mlnext.score.norm_log_likelihood#

mlnext.score.norm_log_likelihood(x: ndarray, mean: ndarray, log_var: ndarray) ndarray[source]#

Calculates the negative log likelihood that x was drawn from a normal gaussian distribution defined by mean and log_var.

\[ \begin{align}\begin{aligned}f(x|\mu, \sigma) = \frac{1}{\sqrt{2\pi\sigma^2}}\exp{-\frac{1} {2}(\frac{x-\mu}{\sigma})^2}\\\text{Log likelihood}: log(f(x | \mu, \sigma)) = -0.5 (\log(2\pi) + (x-\mu)^2/\sigma^2 + \log(\sigma^2))\end{aligned}\end{align} \]
Parameters:
  • x (np.ndarray) – Sample.

  • mean (np.ndarray) – Mean of the gaussian normal distribution.

  • log_var (np.ndarray) – Log variance of the gaussian normal distribution.

Returns:

Returns the negative log likelihood.

Return type:

np.ndarray