All problems
Gaussian Product of Experts
Problem
A product of independent Gaussian experts with means means[i] and standard deviations sigmas[i] is again Gaussian. Its precision is the sum of the expert precisions 1 / sigmas[i]^2, and its mean is the precision-weighted average of the expert means. Return [mean, standard deviation] or [0.0, 0.0] for empty, mismatched or nonpositive input.
Hint
Multiply the Gaussian densities: precisions add and precision-weighted means add.
Test cases
case 1
in: [[0,1],[1,1]]
expected: [0.5,0.7071067811865475]
case 2
in: [[0,0],[1,2]]
expected: [0,0.8944271909999159]
case 3
in: [[1,2,3],[1,1,1]]
expected: [2,0.5773502691896258]
case 4
in: [[2],[0.5]]
expected: [2,0.5]
case 5
in: [[0,10],[1,0.1]]
expected: [9.900990099009901,0.09950371902099892]
Starter codePython
import math
def gaussian_product_of_experts(means, sigmas):
# Your code here
pass5 test cases · run your code against them in the editor