Skip to content

Instantly share code, notes, and snippets.

@zhjgithub
Created October 15, 2018 08:43
Show Gist options
  • Save zhjgithub/e2ea28ef1aafd741b606e8e226fe2d2f to your computer and use it in GitHub Desktop.
Save zhjgithub/e2ea28ef1aafd741b606e8e226fe2d2f to your computer and use it in GitHub Desktop.
To compute the measure of correlation between two Boolean variables. The output of the formula is a number between -1 and 1 that describes the correlation.
function phi([n00, n01, n10, n11]) {
return (n11 * n00 - n10 * n01) /
Math.sqrt((n10 + n11) *
(n00 + n01) *
(n01 + n11) *
(n00 + n10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment