All problems
Proportion Mediated
Problem
Return the proportion mediated a*b/c, the share of the total effect that flows through the mediator. Return 0.0 when the total effect c is zero.
Hint
Divide the indirect effect by the total effect.
Test cases
case 1
in: [0.5,0.4,2]
expected: 0.1
case 2
in: [1,1,0]
expected: 0
case 3
in: [-0.5,0.4,1]
expected: -0.2
case 4
in: [0.5,0.5,0.5]
expected: 0.5
Starter codePython
def proportion_mediated(a, b, c):
# Your code here
pass4 test cases · run your code against them in the editor