All problems
Friendship Paradox Multiplier
Problem
The average degree of a uniformly random neighbor of a uniformly random person is size-biased:
E[neighbor degree] = E[D^2] / E[D] = (variance + mean^2) / mean.
Return the multiplier over the average degree. Return 0.0 for mean_degree <= 0.
Hint
Neighbors are sampled with probability proportional to their degree.
Test cases
case 1
in: [4,4]
expected: 5
case 2
in: [2,1]
expected: 2.5
case 3
in: [10,90]
expected: 19
case 4
in: [0,1]
expected: 0
Starter codePython
def friendship_paradox_multiplier(mean_degree, variance_degree):
# Your code here
pass4 test cases · run your code against them in the editor