|
| 1 | +^:kindly/hide-code |
| 2 | +(ns math.stats.quantquestions.what-are-the-odds.cheat-zine |
| 3 | + {:clay {:title "A Survival Themed Probability Cheatsheet Zine" |
| 4 | + ;; NOTE: `:static true` tells Clay to export SVGs as images so they can be compiled into the PDF. |
| 5 | + :kindly/options {:static true |
| 6 | + :kinds-that-hide-code #{:kind/var :kind/hiccup}} |
| 7 | + ;; NOTE: Typst configuration. Typst is a PDF compiler. |
| 8 | + ;; See the {=typst} block at the start of the content, |
| 9 | + ;; where the zen-zine plugin is activated. |
| 10 | + :quarto {:format {:typst {:papersize :us-letter |
| 11 | + :fontsize "8pt"}} |
| 12 | + ;; NOTE: overriding theme to make more printer friendly |
| 13 | + :theme :flatly |
| 14 | + :brand false |
| 15 | + :number-sections false |
| 16 | + :image "cheat_zine.png" |
| 17 | + :author [:timothypratley] |
| 18 | + :description "A printable PDF of an 8-panel foldable probability zine built with Clay." |
| 19 | + :abstract "This zine sheet folds into 8 small pages. Space is tight, so it focuses on a few core ideas instead of full definitions; counting outcomes, choosing the right denominator, using AND/OR/NOT, and conditional probability. The layout and fold structure are handled by the zen-zine Typst plugin. The zine is for quick learning and quick checks of understanding, such as a short discussion with a nephew or niece." |
| 20 | + :date "2026-06-20" |
| 21 | + :category :stats |
| 22 | + :tags [:stats :probability :zine :print :typst]}}} |
| 23 | + ;; NOTE: Plotje output is SVG, which is perfect to use with `:static true` for PDF. |
| 24 | + (:require [scicloj.plotje.api :as pj])) |
| 25 | + |
| 26 | +;; ```{=typst} |
| 27 | +;; #import "@preview/zen-zine:0.4.0": zine8 |
| 28 | +;; #show: zine8 |
| 29 | +;; ``` |
| 30 | + |
| 31 | +;; # Will You Survive? |
| 32 | + |
| 33 | +;; ### Island Survival Guide |
| 34 | + |
| 35 | +;; You are stranded on an island. |
| 36 | +;; The difference between rescue and disaster lies in the data. |
| 37 | +;; This is your survival guide to probability and statistics. |
| 38 | +;; Learn the patterns, and maybe you will get rescued. |
| 39 | + |
| 40 | +;; ::: {.content-visible when-format="html"} |
| 41 | +;; ::: {.callout-note} |
| 42 | +;; This page is a companion to a printable foldable zine. |
| 43 | +;; See [the PDF](cheat_zine.pdf) to view the 8-panel print layout. |
| 44 | +;; ::: |
| 45 | +;; ::: |
| 46 | + |
| 47 | +;;  |
| 48 | + |
| 49 | +;; {{< pagebreak >}} |
| 50 | + |
| 51 | +;; ## Enumerate and count |
| 52 | + |
| 53 | +;; $P(E) = \frac{\text{favorable outcomes}}{\text{total outcomes}}$ |
| 54 | + |
| 55 | +;; Check 10 nearby trees. |
| 56 | +;; Count the outcomes you care about, then divide by the number of trees. |
| 57 | +;; Enumeration means listing possible outcomes so you can count them. |
| 58 | + |
| 59 | +^:kindly/hide-code |
| 60 | +(let [fruiting? #{1 7} |
| 61 | + step 22] |
| 62 | + (into |
| 63 | + ^:kind/hiccup |
| 64 | + [:svg {:viewBox "0 0 260 84" :width "100%" :style {:background "#ffffff"}} |
| 65 | + [:text {:x 120 :y 16 :text-anchor "middle" :font-size 14 :font-weight 700 :fill "#111827"} |
| 66 | + "Tree Fruiting Probability"]] |
| 67 | + (concat |
| 68 | + (for [i (range 10) |
| 69 | + :let [x (+ 20 (* i step)) |
| 70 | + fruit? (contains? fruiting? i)]] |
| 71 | + [:g |
| 72 | + [:rect {:x x :y 28 :width 16 :height 16 :rx 3 |
| 73 | + :fill (if fruit? "#fef3c7" "#e5e7eb") |
| 74 | + :stroke (if fruit? "#d97706" "#9ca3af")}] |
| 75 | + (when fruit? |
| 76 | + [:text {:x (+ x 8) :y 40 :text-anchor "middle" :font-size 8 :fill "#92400e"} |
| 77 | + "F"])]) |
| 78 | + [[:text {:x 120 :y 62 :text-anchor "middle" :font-size 9 :fill "#92400e"} |
| 79 | + "Observed fruiting = 2/10"]]))) |
| 80 | + |
| 81 | +;; You sampled 10 trees, but the island has over 100 trees. |
| 82 | +;; So $\frac{2}{10}=0.2$ is a sample-based guess: useful for describing what you observed and predicting future observations. |
| 83 | + |
| 84 | +;; Statistics use past observations (like 2 of 10 trees) to estimate a probability. |
| 85 | +;; Probability uses that estimate to predict what will happen at the next tree. |
| 86 | +;; Probability rules show how to combine predictions into complex scenarios. |
| 87 | + |
| 88 | +;; {{< pagebreak >}} |
| 89 | + |
| 90 | +;; ## The AND Rule |
| 91 | + |
| 92 | +;; $P(A \text{ and } B) = P(A) \times P(B)$ |
| 93 | + |
| 94 | +;; You make two foraging stops before dark; how much fruit should you expect? |
| 95 | +;; Linked events shrink your chances; multiply the probabilities along the branches. Each requirement filters out more possibilities, so you need both to happen. |
| 96 | + |
| 97 | +^:kindly/hide-code |
| 98 | +(let [cell 12 |
| 99 | + pad 34 |
| 100 | + cols 10 |
| 101 | + rows 10 |
| 102 | + a-cols 2 ;; tree 1 fruiting = 2/10 |
| 103 | + b-rows 2] ;; tree 2 fruiting = 2/10 |
| 104 | + (into |
| 105 | + ^:kind/hiccup |
| 106 | + [:svg {:viewBox "0 0 300 180" :width "100%" :style {:background "#ffffff"}} |
| 107 | + [:text {:x 130 :y 16 :text-anchor "middle" :font-size 14 :font-weight 700 :fill "#111827"} |
| 108 | + "AND is an intersection of outcomes"] |
| 109 | + [:text {:x 20 :y 97 :transform "rotate(-90 20 97)" :font-size 9 :fill "#374151"} |
| 110 | + "Tree2 fruiting"] |
| 111 | + [:text {:x 93 :y 172 :text-anchor "middle" :font-size 9 :fill "#374151"} |
| 112 | + "Tree1 fruiting"]] |
| 113 | + (concat |
| 114 | + (for [r (range rows) |
| 115 | + c (range cols) |
| 116 | + :let [x (+ pad (* c cell)) |
| 117 | + y (+ 38 (* r cell)) |
| 118 | + in-a? (< c a-cols) |
| 119 | + in-b? (< r b-rows) |
| 120 | + fill (cond |
| 121 | + (and in-a? in-b?) "#84cc16" ;; A and B |
| 122 | + in-a? "#dbeafe" ;; A only |
| 123 | + in-b? "#fef3c7" ;; B only |
| 124 | + :else "#f3f4f6") |
| 125 | + stroke (if (and in-a? in-b?) "#4d7c0f" "#9ca3af")]] |
| 126 | + [:rect {:x x :y y :width 10 :height 10 :rx 1.5 :fill fill :stroke stroke}]) |
| 127 | + [[:rect {:x 186 :y 146 :width 98 :height 20 :rx 4 :fill "#ecfccb" :stroke "#84cc16"}] |
| 128 | + [:text {:x 235 :y 159 :text-anchor "middle" :font-size 9 :fill "#365314"} |
| 129 | + "A and B = 4/100"]]))) |
| 130 | + |
| 131 | +;; If each tree has fruit chance $2/10$ (0.2), then |
| 132 | +;; $P(\text{tree1 fruiting AND tree2 fruiting}) = 0.2 \times 0.2 = 0.04$ (4%). |
| 133 | + |
| 134 | +;; {{< pagebreak >}} |
| 135 | + |
| 136 | +;; ## The OR Rule |
| 137 | + |
| 138 | +;; $P(A \text{ or } B) = P(A) + P(B)$ |
| 139 | + |
| 140 | +;; It's a new day! Time to collect more fruit. |
| 141 | +;; A tree can be a coconut tree or a bananna tree, but not both at once. |
| 142 | +;; When you visit a tree, the type of tree is mutually exclusive. |
| 143 | + |
| 144 | +^:kindly/hide-code |
| 145 | +(let [coconut? #{1 7} |
| 146 | + banana? #{3 8 9} |
| 147 | + step 22] |
| 148 | + (into |
| 149 | + ^:kind/hiccup |
| 150 | + [:svg {:viewBox "0 0 260 98" :width "100%" :style {:background "#ffffff"}} |
| 151 | + [:text {:x 130 :y 16 :text-anchor "middle" :font-size 14 :font-weight 700 :fill "#111827"} |
| 152 | + "Tree Types"]] |
| 153 | + (concat |
| 154 | + (for [i (range 10) |
| 155 | + :let [x (+ 20 (* i step)) |
| 156 | + is-coconut? (contains? coconut? i) |
| 157 | + is-banana? (contains? banana? i) |
| 158 | + fill (cond |
| 159 | + is-coconut? "#fef3c7" |
| 160 | + is-banana? "#dbeafe" |
| 161 | + :else "#e5e7eb") |
| 162 | + stroke (cond |
| 163 | + is-coconut? "#d97706" |
| 164 | + is-banana? "#2563eb" |
| 165 | + :else "#9ca3af") |
| 166 | + label (cond |
| 167 | + is-coconut? "C" |
| 168 | + is-banana? "B" |
| 169 | + :else "O") |
| 170 | + text-fill (cond |
| 171 | + is-coconut? "#92400e" |
| 172 | + is-banana? "#1e40af" |
| 173 | + :else "#6b7280")]] |
| 174 | + [:g |
| 175 | + [:rect {:x x :y 32 :width 16 :height 16 :rx 3 :fill fill :stroke stroke}] |
| 176 | + [:text {:x (+ x 8) :y 43 :text-anchor "middle" :font-size 8 :fill text-fill} |
| 177 | + label]]) |
| 178 | + [[:text {:x 58 :y 68 :text-anchor "middle" :font-size 8 :fill "#92400e"} |
| 179 | + "Coconut = 2/10"] |
| 180 | + [:text {:x 132 :y 68 :text-anchor "middle" :font-size 8 :fill "#1e40af"} |
| 181 | + "Banana = 3/10"] |
| 182 | + [:text {:x 208 :y 68 :text-anchor "middle" :font-size 8 :fill "#6b7280"} |
| 183 | + "Other = 5/10"] |
| 184 | + [:text {:x 130 :y 86 :text-anchor "middle" :font-size 9 :fill "#365314"} |
| 185 | + "Coconut or Banana = 5/10"]]))) |
| 186 | + |
| 187 | +;; A tree cannot be both types at once, so just add the probabilities. |
| 188 | +;; $P(\text{coconut or banana}) = \frac{2}{10} + \frac{3}{10} = \frac{5}{10} = 0.5$. |
| 189 | + |
| 190 | +;; If categories can overlap, adding $P(A)$ and $P(B)$ counts shared cases twice. |
| 191 | +;; Subtract the overlap once to fix that double-counting. |
| 192 | +;; Use $P(A \text{ or } B)=P(A)+P(B)-P(A \text{ and } B)$. |
| 193 | + |
| 194 | +;; tall or fruiting = tall + fruiting - tall and fruiting. |
| 195 | + |
| 196 | +;; {{< pagebreak >}} |
| 197 | + |
| 198 | +;; ## The NOT Rule |
| 199 | + |
| 200 | +;; $P(\text{not } E) = 1 - P(E)$ |
| 201 | + |
| 202 | +;; Night is coming; you need to find at least one fruit. |
| 203 | +;; If you visit 3 trees with $P(fruit)=\frac{2}{10}$, what is the chance you get at least one fruit? |
| 204 | +;; Use the NOT rule when the event you want is hard to count, but its opposite is easy. |
| 205 | + |
| 206 | +^:kindly/hide-code |
| 207 | +^:kind/hiccup |
| 208 | +[:svg {:viewBox "0 0 520 190" :width "100%" :style {:background "#ffffff"}} |
| 209 | + [:text {:x 260 :y 16 :text-anchor "middle" :font-size 12 :font-weight 700 :fill "#111827"} |
| 210 | + "Solve the Easier Problem"] |
| 211 | + [:circle {:cx 40 :cy 95 :r 14 :fill "#0f766e"}] |
| 212 | + [:text {:x 40 :y 99 :text-anchor "middle" :font-size 8 :fill "white"} "V1"] |
| 213 | + [:circle {:cx 140 :cy 60 :r 12 :fill "#2563eb"}] |
| 214 | + [:text {:x 140 :y 64 :text-anchor "middle" :font-size 8 :fill "white"} "N"] |
| 215 | + [:circle {:cx 140 :cy 130 :r 12 :fill "#f59e0b"}] |
| 216 | + [:text {:x 140 :y 134 :text-anchor "middle" :font-size 8 :fill "#111827"} "F"] |
| 217 | + [:circle {:cx 240 :cy 35 :r 11 :fill "#2563eb"}] |
| 218 | + [:text {:x 240 :y 39 :text-anchor "middle" :font-size 7 :fill "white"} "NN"] |
| 219 | + [:circle {:cx 240 :cy 75 :r 11 :fill "#f59e0b"}] |
| 220 | + [:text {:x 240 :y 79 :text-anchor "middle" :font-size 7 :fill "#111827"} "NF"] |
| 221 | + [:circle {:cx 240 :cy 115 :r 11 :fill "#f59e0b"}] |
| 222 | + [:text {:x 240 :y 119 :text-anchor "middle" :font-size 7 :fill "#111827"} "FN"] |
| 223 | + [:circle {:cx 240 :cy 155 :r 11 :fill "#f59e0b"}] |
| 224 | + [:text {:x 240 :y 159 :text-anchor "middle" :font-size 7 :fill "#111827"} "FF"] |
| 225 | + [:line {:x1 52 :y1 90 :x2 128 :y2 65 :stroke "#2563eb" :stroke-width 1.8}] |
| 226 | + [:line {:x1 52 :y1 100 :x2 128 :y2 125 :stroke "#d97706" :stroke-width 1.8}] |
| 227 | + [:line {:x1 151 :y1 55 :x2 229 :y2 38 :stroke "#2563eb" :stroke-width 1.6}] |
| 228 | + [:line {:x1 151 :y1 65 :x2 229 :y2 72 :stroke "#d97706" :stroke-width 1.6}] |
| 229 | + [:line {:x1 151 :y1 125 :x2 229 :y2 118 :stroke "#d97706" :stroke-width 1.6}] |
| 230 | + [:line {:x1 151 :y1 135 :x2 229 :y2 152 :stroke "#d97706" :stroke-width 1.6}] |
| 231 | + [:line {:x1 251 :y1 30 :x2 336 :y2 22 :stroke "#2563eb" :stroke-width 1.4}] |
| 232 | + [:line {:x1 251 :y1 40 :x2 336 :y2 42 :stroke "#d97706" :stroke-width 1.4}] |
| 233 | + [:line {:x1 251 :y1 70 :x2 336 :y2 62 :stroke "#d97706" :stroke-width 1.4}] |
| 234 | + [:line {:x1 251 :y1 80 :x2 336 :y2 82 :stroke "#d97706" :stroke-width 1.4}] |
| 235 | + [:line {:x1 251 :y1 110 :x2 336 :y2 102 :stroke "#d97706" :stroke-width 1.4}] |
| 236 | + [:line {:x1 251 :y1 120 :x2 336 :y2 122 :stroke "#d97706" :stroke-width 1.4}] |
| 237 | + [:line {:x1 251 :y1 150 :x2 336 :y2 142 :stroke "#d97706" :stroke-width 1.4}] |
| 238 | + [:line {:x1 251 :y1 160 :x2 336 :y2 162 :stroke "#d97706" :stroke-width 1.4}] |
| 239 | + [:rect {:x 336 :y 16 :width 48 :height 12 :rx 3 :fill "#dbeafe" :stroke "#2563eb"}] |
| 240 | + [:text {:x 360 :y 24 :text-anchor "middle" :font-size 7 :fill "#1e40af"} "NNN"] |
| 241 | + [:rect {:x 336 :y 36 :width 48 :height 12 :rx 3 :fill "#fef3c7" :stroke "#d97706"}] |
| 242 | + [:text {:x 360 :y 44 :text-anchor "middle" :font-size 7 :fill "#92400e"} "NNF"] |
| 243 | + [:rect {:x 336 :y 56 :width 48 :height 12 :rx 3 :fill "#fef3c7" :stroke "#d97706"}] |
| 244 | + [:text {:x 360 :y 64 :text-anchor "middle" :font-size 7 :fill "#92400e"} "NFN"] |
| 245 | + [:rect {:x 336 :y 76 :width 48 :height 12 :rx 3 :fill "#fef3c7" :stroke "#d97706"}] |
| 246 | + [:text {:x 360 :y 84 :text-anchor "middle" :font-size 7 :fill "#92400e"} "NFF"] |
| 247 | + [:rect {:x 336 :y 96 :width 48 :height 12 :rx 3 :fill "#fef3c7" :stroke "#d97706"}] |
| 248 | + [:text {:x 360 :y 104 :text-anchor "middle" :font-size 7 :fill "#92400e"} "FNN"] |
| 249 | + [:rect {:x 336 :y 116 :width 48 :height 12 :rx 3 :fill "#fef3c7" :stroke "#d97706"}] |
| 250 | + [:text {:x 360 :y 124 :text-anchor "middle" :font-size 7 :fill "#92400e"} "FNF"] |
| 251 | + [:rect {:x 336 :y 136 :width 48 :height 12 :rx 3 :fill "#fef3c7" :stroke "#d97706"}] |
| 252 | + [:text {:x 360 :y 144 :text-anchor "middle" :font-size 7 :fill "#92400e"} "FFN"] |
| 253 | + [:rect {:x 336 :y 156 :width 48 :height 12 :rx 3 :fill "#fef3c7" :stroke "#d97706"}] |
| 254 | + [:text {:x 360 :y 164 :text-anchor "middle" :font-size 7 :fill "#92400e"} "FFF"] |
| 255 | + [:rect {:x 420 :y 26 :width 90 :height 16 :rx 4 :fill "#dbeafe" :stroke "#2563eb"}] |
| 256 | + [:text {:x 465 :y 37 :text-anchor "middle" :font-size 8 :fill "#1e40af"} "No fruit: NNN"] |
| 257 | + [:rect {:x 420 :y 50 :width 90 :height 16 :rx 4 :fill "#fef3c7" :stroke "#d97706"}] |
| 258 | + [:text {:x 465 :y 61 :text-anchor "middle" :font-size 8 :fill "#92400e"} "Has fruit: 7 paths"]] |
| 259 | + |
| 260 | +;; $P(not fruit) = 1 - \frac{2}{10} = \frac{8}{10}$ |
| 261 | + |
| 262 | +;; $P(\text{no fruit in 3 trees}) = \frac{8}{10}\times\frac{8}{10}\times\frac{8}{10} = 0.512$. |
| 263 | + |
| 264 | +;; Invert back to the original question: |
| 265 | + |
| 266 | +;; $P(\text{at least one fruit}) = 1 - 0.512 = 0.488$. |
| 267 | + |
| 268 | +;; {{< pagebreak >}} |
| 269 | + |
| 270 | +;; ## The "Given That" Rule |
| 271 | + |
| 272 | +;; $P(A \mid B) = \frac{P(A \text{ and } B)}{P(B)}$ |
| 273 | + |
| 274 | +;; The bar symbol $|$ means "given". |
| 275 | + |
| 276 | +;; Dark clouds move in, so your wood-gathering plan must adapt to the weather you actually get. |
| 277 | +;; Question prompt us to gather new statistics and probabilities. |
| 278 | + |
| 279 | +^:kindly/hide-code |
| 280 | +^:kind/hiccup |
| 281 | +[:svg {:viewBox "0 0 560 300" :width "100%" :style {:background "#ffffff"}} |
| 282 | + [:text {:x 280 :y 22 :text-anchor "middle" :font-size 14 :font-weight 700 :fill "#111827"} |
| 283 | + "Island weather affects finding dry wood"] |
| 284 | + [:circle {:cx 70 :cy 150 :r 22 :fill "#0f766e"}] |
| 285 | + [:text {:x 70 :y 155 :text-anchor "middle" :font-size 10 :fill "white"} "All (100)"] |
| 286 | + [:line {:x1 92 :y1 140 :x2 175 :y2 90 :stroke "#0f766e" :stroke-width 2}] |
| 287 | + [:line {:x1 92 :y1 160 :x2 175 :y2 210 :stroke "#0f766e" :stroke-width 2}] |
| 288 | + [:circle {:cx 195 :cy 85 :r 22 :fill "#2563eb"}] |
| 289 | + [:text {:x 195 :y 84 :text-anchor "middle" :font-size 9 :fill "white"} "Rain"] |
| 290 | + [:text {:x 195 :y 95 :text-anchor "middle" :font-size 9 :fill "white"} "(40)"] |
| 291 | + [:circle {:cx 195 :cy 215 :r 22 :fill "#f59e0b"}] |
| 292 | + [:text {:x 195 :y 214 :text-anchor "middle" :font-size 8 :fill "#111827"} "Not Rain"] |
| 293 | + [:text {:x 195 :y 224 :text-anchor "middle" :font-size 8 :fill "#111827"} "(60)"] |
| 294 | + [:line {:x1 217 :y1 77 :x2 320 :y2 55 :stroke "#2563eb" :stroke-width 2}] |
| 295 | + [:line {:x1 217 :y1 93 :x2 320 :y2 115 :stroke "#2563eb" :stroke-width 2}] |
| 296 | + [:line {:x1 217 :y1 207 :x2 320 :y2 185 :stroke "#d97706" :stroke-width 2}] |
| 297 | + [:line {:x1 217 :y1 223 :x2 320 :y2 245 :stroke "#d97706" :stroke-width 2}] |
| 298 | + [:rect {:x 308 :y 35 :width 112 :height 30 :rx 6 :fill "#fef3c7" :stroke "#2563eb"}] |
| 299 | + [:text {:x 364 :y 54 :text-anchor "middle" :font-size 9 :fill "#92400e"} "Dry | Rain (8)"] |
| 300 | + [:rect {:x 308 :y 95 :width 112 :height 30 :rx 6 :fill "#dbeafe" :stroke "#2563eb"}] |
| 301 | + [:text {:x 364 :y 114 :text-anchor "middle" :font-size 9 :fill "#1e40af"} "Not Dry | Rain (32)"] |
| 302 | + [:rect {:x 308 :y 165 :width 112 :height 30 :rx 6 :fill "#fef3c7" :stroke "#d97706"}] |
| 303 | + [:text {:x 364 :y 184 :text-anchor "middle" :font-size 9 :fill "#92400e"} "Dry | Not Rain (54)"] |
| 304 | + [:rect {:x 308 :y 225 :width 112 :height 30 :rx 6 :fill "#dbeafe" :stroke "#d97706"}] |
| 305 | + [:text {:x 364 :y 244 :text-anchor "middle" :font-size 9 :fill "#1e40af"} "Not Dry | Not Rain (6)"] |
| 306 | + [:line {:x1 420 :y1 50 :x2 478 :y2 110 :stroke "#d97706" :stroke-width 1.5 :stroke-dasharray "4 3"}] |
| 307 | + [:line {:x1 420 :y1 180 :x2 478 :y2 110 :stroke "#d97706" :stroke-width 1.5 :stroke-dasharray "4 3"}] |
| 308 | + [:line {:x1 420 :y1 110 :x2 478 :y2 210 :stroke "#60a5fa" :stroke-width 1.5 :stroke-dasharray "4 3"}] |
| 309 | + [:line {:x1 420 :y1 240 :x2 478 :y2 210 :stroke "#60a5fa" :stroke-width 1.5 :stroke-dasharray "4 3"}] |
| 310 | + [:circle {:cx 500 :cy 110 :r 22 :fill "#fef3c7" :stroke "#d97706"}] |
| 311 | + [:text {:x 500 :y 107 :text-anchor "middle" :font-size 8 :fill "#92400e"} "Dry"] |
| 312 | + [:text {:x 500 :y 117 :text-anchor "middle" :font-size 8 :fill "#92400e"} "(62)"] |
| 313 | + [:circle {:cx 500 :cy 210 :r 22 :fill "#dbeafe" :stroke "#2563eb"}] |
| 314 | + [:text {:x 500 :y 207 :text-anchor "middle" :font-size 7 :fill "#1e40af"} "Not Dry"] |
| 315 | + [:text {:x 500 :y 217 :text-anchor "middle" :font-size 8 :fill "#1e40af"} "(38)"]] |
| 316 | + |
| 317 | +;; Probability is about identifying the interesting set of outcomes. |
| 318 | +;; A tree helps you enumerate and count interesting and possible outcomes. |
| 319 | +;; For "dry wood given rain," count within rainy outcomes: $8/40$. |
| 320 | +;; For "rain given dry wood," count within dry outcomes (all yellow): $8/62$. |
| 321 | +;; It's a matter of filtering to cases where the condition is true, then count outcomes inside that filtered group. |
| 322 | + |
| 323 | +;; {{< pagebreak >}} |
| 324 | + |
| 325 | +;; ## Distribution Matters |
| 326 | + |
| 327 | +;; Where will you camp? |
| 328 | +;; Continuous variables like temperature can be any value. |
| 329 | +;; Observations rarely spread evenly; instead, they cluster and vary. |
| 330 | +;; Island A and Island B both average 75°F, yet Island A is highly predictable (72°F to 78°F) while Island B is highly volatile (30°F to 120°F). |
| 331 | +;; To truly understand the situation, we must see the distribution, the shape of the data. |
| 332 | + |
| 333 | +;; ::: {layout-ncol=2} |
| 334 | +^:kindly/hide-code |
| 335 | +(-> [{:temperature "30-44F" :days 0} |
| 336 | + {:temperature "45-59F" :days 0} |
| 337 | + {:temperature "60-74F" :days 38} |
| 338 | + {:temperature "75-89F" :days 62} |
| 339 | + {:temperature "90-104F" :days 0} |
| 340 | + {:temperature "105-119F" :days 0} |
| 341 | + {:temperature "120-134F" :days 0}] |
| 342 | + (pj/lay-value-bar :temperature :days) |
| 343 | + (pj/options {:title "Island A"})) |
| 344 | + |
| 345 | +^:kindly/hide-code |
| 346 | +(-> [{:temperature "30-44F" :days 2} |
| 347 | + {:temperature "45-59F" :days 4} |
| 348 | + {:temperature "60-74F" :days 8} |
| 349 | + {:temperature "75-89F" :days 10} |
| 350 | + {:temperature "90-104F" :days 7} |
| 351 | + {:temperature "105-119F" :days 4} |
| 352 | + {:temperature "120-134F" :days 2}] |
| 353 | + (pj/lay-value-bar :temperature :days) |
| 354 | + (pj/options {:title "Island B"})) |
| 355 | +;; ::: |
| 356 | + |
| 357 | +;; A distribution reveals where observations cluster and how frequently they occur. |
| 358 | +;; Variance quantifies this spread by measuring the average squared distance from the mean. |
| 359 | +;; A wider spread generally implies higher variance, but the exact value depends on the range and the shape of the distribution. |
| 360 | + |
| 361 | +;; {{< pagebreak >}} |
| 362 | + |
| 363 | +;; ## Survival Quiz |
| 364 | + |
| 365 | +;; {width="50%" fig-align="center"} |
| 366 | + |
| 367 | +;; Time to try to use your radio to contact help. |
| 368 | + |
| 369 | +;; a. Your radio has a $\frac{2}{3}$ failure rate. What is the probability that your signal is successful? |
| 370 | +;; b. Finding fruit and using the radio are independent events. If fruit is found $\frac{2}{10}$ of the time and the radio works $\frac{1}{3}$ of the time, what is the probability that both happen? |
| 371 | +;; c. Rainfall data shows most days have 0 mm of rain, but one rare day has a 600 mm flood. How would you describe the shape of this distribution? |
| 372 | +;; d. Land Area A has a height standard deviation of 2 ft (very flat). Land Area B has a height standard deviation of 80 ft (very rugged). Which area is more likely to contain a mountain peak? |
0 commit comments