All problems
Biserial Correlation
Problem
Return the biserial correlation between continuous scores and a 0/1 group indicator: (mean_1 - mean_0)/s * (p*q)/phi(z_cut), where p is the proportion coded 1, s is the population standard deviation of scores, and phi(z_cut) is the standard normal density at the supplied z_cut. Return 0.0 when a group is missing, lengths differ, or the scores are constant.
Hint
The biserial correlation assumes an underlying continuous, normal variable.
Test cases
case 1
in: [[1,2,3,4],[0,0,1,1],0]
expected: 1.1209982432795857
case 2
in: [[5,4,3,2],[1,0,1,0],0]
expected: 0.5604991216397929
case 3
in: [[1,1,2,2],[1,1,0,0],0]
expected: -1.2533141373155001
case 4
in: [[1,2],[1,1],0]
expected: 0
case 5
in: [[2,2,2],[1,1,0],0]
expected: 0
Starter codePython
import math
def biserial_correlation(scores, groups, z_cut):
# Your code here
pass5 test cases · run your code against them in the editor