55
66= Data Structures: Objects and Arrays =
77
8+ [chapterquote="true"]
89[quote, Charles Babbage, Passages from the Life of a Philosopher (1864)]
910____
1011On two occasions I have been asked, ‘Pray, Mr. Babbage, if you put
@@ -446,7 +447,7 @@ number of times the various combinations of the two variables were
446447observed. For example, we could take the event of eating pizza and
447448put that in a table like this:
448449
449- image::img/pizza-squirrel.svg[alt="Eating pizza versus turning into a squirrel",width="8cm "]
450+ image::img/pizza-squirrel.svg[alt="Eating pizza versus turning into a squirrel",width="7cm "]
450451
451452_ϕ_ can be computed using the following formula, where n refers to the table:
452453
@@ -469,22 +470,22 @@ endif::html_target[]
469470
470471ifdef::tex_target[]
471472
472- latexmath :[\phi = \frac{n_{11}n_{00}-n_{10}n_{01}}{\sqrt{n_{1\bullet}n_{0\bullet}n_{\bullet1}n_{\bullet0}}}]
473+ pass :[\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 }]
473474
474475endif::tex_target[]
475476
476- The notation _n_~01~ indicates the number of measurements where the first
477+ The notation (!html _n_~01~!)(!tex pass:[$n_{01}$]!) indicates the number of measurements where the first
477478measurement (pizza) is false (0) and the second measurement (squirrelness) is
478- true (1). In this example, _n_~01~ is 4.
479+ true (1). In this example, (!html _n_~01~!)(!tex pass:[$n_{01}$]!) is 4.
479480
480- The value _n_~1•~ refers to the sum of all
481+ The value (!html _n_~1•~!)(!tex pass:[$n_{1\bullet}$]!) refers to the sum of all
481482measurements where the first variable is true, which is 10 in the
482- example table. Likewise, _n_~•0~ refers to the sum of the measurements where
483+ example table. Likewise, (!html _n_~•0~!)(!tex pass:[$n_{\bullet0}$]!) refers to the sum of the measurements where
483484the squirrel variable is false.
484485
485486So for the pizza table, the part above the division line (the dividend)
486487would be 1×76 - 9×4 = 40, and the part below it (the divisor) would be the
487- square root of 10×80×5×85, or √340000. This comes out to _ϕ_ ≈ 0.069. This
488+ square root of 10×80×5×85, or (!html √340000!)(!tex pass:[$\sqrt{340000}$]!) . This comes out to _ϕ_ ≈ 0.069, which
488489is tiny. Eating pizza does not appear to have influence on the
489490transformations.
490491
@@ -526,12 +527,12 @@ console.log(phi([76, 9, 4, 1]));
526527(((square root)))(((sqrt function)))This is simply a direct translation
527528of the _phi_ formula into JavaScript. `Math.sqrt` is the square root function,
528529as provided by the `Math` object in a standard JavaScript environment.
529- We have to sum two fields from the table to get fields like n~1•~
530+ We have to sum two fields from the table to get fields like (!html n~1•~!)(!tex pass:[$n_{1\bullet}$]!)
530531because the sums of rows or columns are not stored directly in our
531532data structure.
532533
533534Jacques kept his journal for three months. The resulting data set is
534- available in the coding sandbox for this chapter!! tex (`eloquentjavascript.net/code`)!! ,
535+ available in the coding sandbox for this chapter(! tex (`eloquentjavascript.net/code`)!) ,
535536where it is stored
536537in the `JOURNAL` variable, and in a downloadable
537538http://eloquentjavascript.net/code/jacques_journal.js[file].
0 commit comments