Eloquent Javascript - correlation and coefficient Currently I'm reading Eloquent Javascript book and at chapter 4. This topic entitled 'The lycanthrope’s log ' is very confusing to me. How important is correlation and coefficient in real world programming?
I'm trying to understand the formula used to find correlation. I've far forgotten maths since I left my high school. Could, someone who've read this book, explain to me in detail, please? Below is the picture I'm wondering about.. 

 A: The formula is actually pretty straight forward. Consider the table from your question. 

The table states that there were a total 90 observations

Out of all 90 observations:


*

*76 times, no pizzas or squirrel

*9 times, pizzas but no squirrel

*4 times, squirrel but no pizzas

*1 time, both squirrel and pizza



So we want to find out how Pizzas & Squirrels are related:


Consider the equation along with your table now,
(since squirrel is on the left)
n00 denotes an observation where there was no squirrel or pizza (1)
n01 denotes an observation where there was no squirrel but pizza (2)
n10 denotes an observation where there was squirrel but no pizza (3)
n11 denotes an observation where there was both squirrel but pizza (4)

n0. refers to the sum of all measurements where we have no squirrel
n.0 refers to the sum of all measurements where we have no pizza
n1. refers to the sum of all measurements where we have squirrel
n.1 refers to the sum of all measurements where we have pizza

Now that we know what these values are, let's plug them in to our formula:
$$    \mathit{correlation} = \rho = \frac{ 1 \times 76 - 4 \times 9}{\sqrt{5 \times 85 \times 10 \times 80}}$$
A: Maybe it's too late since this question was asked 5 years, 9 months ago. But I hope my explanation will help you to understand the phi coefficient in this book better. Things we know from this book are:

*

*The first variable is the squirrel.

*the second variable is the pizza.

*If the variable is false it is 0.

*If the variable is true it is 1.

Based on that we can compile the first line of the phi coefficient's formula:

*

*n11 both of the variables are true (both squirrel and pizza are true): the value is 1.

*n00 both of the variables are false (both squirrel and pizza are false): the value is 76.

*n10 the first variable/squirrel is true but the pizza is false: the value is 4.

*n01 the first variable is false and the second is true: 9.

So, for the second line (√ n1• x n0• x n•1 x n•0), we need to see where the number and the dot (.) are located. If the dot is after the number, then we are talking about the first value which is a squirrel with 0 or 1 indicating the true or false. And vice versa. For example:

*

*n1. : the dot is after a number so we are talking about the first variable which is a squirrel and 1 is true, so we need to sum everything where the squirrel is true (4 + 1)

*n0. : the squirrel is false (76 + 9)

*n.1 : the dot is before the number so we are talking about the second variable which is pizza and 1 is true, so we need to sum everything where the pizza is true (9 + 1)

*n.0 : the pizza is false (76 + 4)

I hope my explanation will help anyone in the future who stumbles upon this problem and grasp the concept as easy as possible. Cheers!
