All problems
Gaussian Gibbs Conditional Mean
Problem
For a bivariate Gaussian with means mu1 and mu2, standard deviations sigma1 and sigma2, and correlation rho, the conditional mean of the first coordinate given the second is mu1 + rho * (sigma1 / sigma2) * (x2 - mu2). Return that mean, or 0.0 for invalid parameters.
Hint
This is the Gibbs sampling update for one coordinate of a bivariate normal.
Test cases
case 1
in: [0,0,1,1,0.5,1]
expected: 0.5
case 2
in: [1,2,2,1,0.5,3]
expected: 2
case 3
in: [0,0,1,2,0.8,4]
expected: 1.6
case 4
in: [3,3,1,1,0,7]
expected: 3
case 5
in: [0,0,1,1,1.5,1]
expected: 0
Starter codePython
def gaussian_gibbs_conditional_mean(mu1, mu2, sigma1, sigma2, rho, x2):
# Your code here
pass5 test cases · run your code against them in the editor