All problems
Regression to the Mean Prediction
Problem
With overall mean mean and correlation rho between two measurements, the predicted second measurement for a first measurement x regresses toward the mean:
prediction = mean + rho * (x - mean).
Return the prediction.
Hint
With perfect correlation the prediction stays at x; with zero correlation it collapses to the mean.
Test cases
case 1
in: [0,1,0.5]
expected: 0.5
case 2
in: [100,120,0.7]
expected: 114
case 3
in: [0,2,0]
expected: 0
case 4
in: [50,50,0.9]
expected: 50
Starter codePython
def regression_to_mean_prediction(mean, x, rho):
# Your code here
pass4 test cases · run your code against them in the editor