Gaussian Log-Likelihood

Medium
~20 min
code completion

Gaussian Log-Likelihood

A Gaussian (Normal) distribution with mean and standard deviation has probability density:

In practice we work with the log-likelihood to avoid numerical underflow:

For a dataset of independent observations , the total log-likelihood is the sum.

Your task:

Implement gaussian_log_likelihood(x, mu, sigma) that returns the total (summed) log-likelihood over all observations in x.

Example Tests

Single point at the mean: maximum log-likelihood for sigma=1

Input: {"x":[0],"mu":0,"sigma":1}

Expected: -0.91894

Two points equidistant from mean

Input: {"x":[-1,1],"mu":0,"sigma":1}

Expected: -2.83788

Larger sigma reduces log-likelihood at mean

Input: {"x":[0],"mu":0,"sigma":2}

Expected: -1.61209

Sign in to solve this problem

You can read the full problem statement above. Create a free account to run code in the browser, submit solutions, and track your progress.