@@ -479,7 +479,8 @@ _ϕ_ can be computed using the following formula, where n refers to the table:
479479ifdef::html_target[]
480480
481481++++
482- <style>sub { font-size: 60%; }</style>
482+ <div>
483+ <style scoped="scoped">sub { font-size: 60%; }</style>
483484<table style="border-collapse: collapse; margin-left: 1em;"><tr>
484485 <td style="vertical-align: middle"><em>ϕ</em> =</td>
485486 <td style="padding-left: .5em">
@@ -489,30 +490,31 @@ ifdef::html_target[]
489490 </span></div>
490491 </td>
491492</tr></table>
493+ </div>
492494++++
493495
494496endif::html_target[]
495497
496- ifdef::book_target []
498+ ifdef::tex_target []
497499
498500pass:[\begin{equation}\phi = \frac{n_{11}n_{00}-n_{10}n_{01}}{\sqrt{n_{1\bullet}n_{0\bullet}n_{\bullet1}n_{\bullet0}}}\end{equation}]
499501
500- endif::book_target []
502+ endif::tex_target []
501503
502- The notation (!html _n_~01~!)(!book pass:[$n_{01}$]!) indicates the
504+ The notation (!html _n_~01~!)(!tex pass:[$n_{01}$]!) indicates the
503505number of measurements where the first measurement (pizza) is false
504506(0) and the second measurement (squirrelness) is true (1). In this
505- example, (!html _n_~01~!)(!book pass:[$n_{01}$]!) is 4.
507+ example, (!html _n_~01~!)(!tex pass:[$n_{01}$]!) is 4.
506508
507- The value (!html _n_~1•~!)(!book pass:[$n_{1\bullet}$]!) refers to the
509+ The value (!html _n_~1•~!)(!tex pass:[$n_{1\bullet}$]!) refers to the
508510sum of all measurements where the first variable is true, which is 10
509- in the example table. Likewise, (!html _n_~•0~!)(!book pass:[$n_{\bullet0}$]!)
511+ in the example table. Likewise, (!html _n_~•0~!)(!tex pass:[$n_{\bullet0}$]!)
510512refers to the sum of the measurements where the squirrel variable is false.
511513
512514(((correlation)))(((phi coefficient)))So for the pizza table, the part
513515above the division line (the dividend) would be 1×76 - 9×4 = 40, and
514516the part below it (the divisor) would be the square root of
515- 10×80×5×85, or (!html √340000!)(!book pass:[$\sqrt{340000}$]!). This
517+ 10×80×5×85, or (!html √340000!)(!tex pass:[$\sqrt{340000}$]!). This
516518comes out to _ϕ_ ≈ 0.069, which is tiny. Eating ((pizza)) does not
517519appear to have influence on the transformations.
518520
@@ -556,7 +558,7 @@ console.log(phi([76, 9, 4, 1]));
556558translation of the _ϕ_ formula into JavaScript. `Math.sqrt` is the
557559square root function, as provided by the `Math` object in a standard
558560JavaScript environment. We have to sum two fields from the table to
559- get fields like (!html n~1•~!)(!book pass:[$n_{1\bullet}$]!) because
561+ get fields like (!html n~1•~!)(!tex pass:[$n_{1\bullet}$]!) because
560562the sums of rows or columns are not stored directly in our data
561563structure.
562564
@@ -1186,7 +1188,7 @@ behavior. The function call `range(1, 10, 2)` should return `[1, 3, 5,
118611887, 9]`. Make sure it also works with negative step values so that
11871189`range(5, 2, -1)` produces `[5, 4, 3, 2]`.
11881190
1189- ifdef::html_target []
1191+ ifdef::interactive_target []
11901192
11911193// test: no
11921194
@@ -1199,7 +1201,7 @@ console.log(sum(range(1, 10)));
11991201console.log(range(5, 2, -1));
12001202// → [5, 4, 3, 2]
12011203----
1202- endif::html_target []
1204+ endif::interactive_target []
12031205
12041206!!hint!!
12051207
@@ -1249,7 +1251,7 @@ the notes about side effects and pure functions in the
12491251link:03_functions.html#pure[previous chapter], which variant do you
12501252expect to be useful in more situations? Which one is more efficient?
12511253
1252- ifdef::html_target []
1254+ ifdef::interactive_target []
12531255
12541256// test: no
12551257
@@ -1264,7 +1266,7 @@ reverseArrayInPlace(arrayValue);
12641266console.log(arrayValue);
12651267// → [5, 4, 3, 2, 1]
12661268----
1267- endif::html_target []
1269+ endif::interactive_target []
12681270
12691271!!hint!!
12701272
@@ -1342,7 +1344,7 @@ is no such element.
13421344(((recursion)))If you haven't already, also write a recursive version
13431345of `nth`.
13441346
1345- ifdef::html_target []
1347+ ifdef::interactive_target []
13461348
13471349// test: no
13481350
@@ -1359,7 +1361,7 @@ console.log(prepend(10, prepend(20, null)));
13591361console.log(nth(arrayToList([10, 20, 30]), 1));
13601362// → 20
13611363----
1362- endif::html_target []
1364+ endif::interactive_target []
13631365
13641366!!hint!!
13651367
@@ -1414,7 +1416,7 @@ it produces `"object"` for both values, you should do a deep
14141416comparison. But you have to take one silly exception into account: by
14151417a historical accident, `typeof null` also produces `"object"`.
14161418
1417- ifdef::html_target []
1419+ ifdef::interactive_target []
14181420
14191421// test: no
14201422
@@ -1430,7 +1432,7 @@ console.log(deepEqual(obj, {here: 1, object: 2}));
14301432console.log(deepEqual(obj, {here: {is: "an"}, object: 2}));
14311433// → true
14321434----
1433- endif::html_target []
1435+ endif::interactive_target []
14341436
14351437!!hint!!
14361438
0 commit comments