PhonePe-inspired transaction segmentation model represents each observation with a mixture of Gaussian components. You need to calculate the component responsibility so the team can update assignments during the next EM iteration.
Compute the responsibilities of a one-dimensional Gaussian mixture for the scalar observation x. mu, sigma and pi are arrays holding each component's mean, standard deviation and mixing weight. The posterior is computed in log space, so observations far from every component stay finite.
Implement solve(x, mu, sigma, pi).
Returns. Return a NumPy vector with one probability per component that sums to 1.
Example 1
Input:
solve(0.0, [0.0, 4.0], [1.0, 1.0], [0.5, 0.5])
Output:
[0.999665, 0.000335]
Example 2
Input:
solve(1.0, [0.0, 2.0], [1.0, 1.0], [0.8, 0.2])
Output:
[0.8, 0.2]
Example 3
Input:
solve(100.0, [0.0, 10.0], [1.0, 1.0], [0.5, 0.5])
Output:
[0.0, 1.0]
No results yet
Run your code to check it against the examples, or submit to run every test.