All problems
Point-Biserial Correlation
Problem
Return the point-biserial correlation between continuous scores and a 0/1 group indicator: (mean_1 - mean_0)/s * sqrt(p*q), where s is the population standard deviation of scores. Return 0.0 when a group is missing, the lengths differ, or all scores are equal.
Hint
It is the Pearson correlation with a binary variable.
Test cases
case 1
in: [[1,2,3,4],[0,0,1,1]]
expected: 0.8944271909999159
case 2
in: [[5,4,3,2],[1,0,1,0]]
expected: 0.4472135954999579
case 3
in: [[1,1,2,2],[1,1,0,0]]
expected: -1
case 4
in: [[1,2],[1,1]]
expected: 0
case 5
in: [[2,2,2],[1,1,0]]
expected: 0
Starter codePython
def point_biserial(scores, groups):
# Your code here
pass5 test cases · run your code against them in the editor