Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-249

Mixture Responsibility E-Step

Problem

Compute the responsibility of each Gaussian component for the point x: r[k] = weights[k] * N(x; means[k], sigmas[k]^2) divided by the sum of all component densities. Return the list of responsibilities, or an empty list when inputs are invalid or the total density is 0.

Hint

This is Bayes' rule inside the expectation step of EM.

Test cases

case 1
in: [[0.5,0.5],[0,5],[1,1],0]
expected: [0.9999962733607158,0.0000037266392841865618]
case 2
in: [[0.4,0.6],[0,1],[1,1],0]
expected: [0.5236161377769489,0.476383862223051]
case 3
in: [[1],[3],[2],3]
expected: [1]
case 4
in: [[0.5,0.5],[0,0],[1,1],2]
expected: [0.5,0.5]
case 5
in: [[0.9,0.1],[10,0],[1,1],0]
expected: [1.735874863167526e-21,1]
Starter codePython
import math


def mixture_responsibility(weights, means, sigmas, x):
    # Your code here
    pass

5 test cases · run your code against them in the editor