Sequential Choice Decision Tree
The learner grows, traces and reads a decision tree of a staged choice: leaf counts as products of stage counts (or not, when branching is uneven), and probability trees with conditional branches, where clicking a leaf multiplies along its path, picked leaves add up to an event, and a two-stage tree flips to read P(first | second) (Bayes). Products can be hidden or stepped through so the tree does not answer an exercise.
Used in: Introduction to Probability Theory
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | "Probability tree" or "Decision tree" | Title bar text. |
| stages | object[] | a disease-test tree (Condition, then Test) | Explicit stages, root to leaves: [{name?, options?, probabilities?, given?, count?}]. name = column heading. options = branch labels under every node of the previous stage: a list of labels, [label, p] pairs or {label, p} objects, or a string ("A-Z", "0-9", "H,T"); probabilities = matching list. given = per-parent branches when the stage depends on the path: {"Disease": {"Positive": 0.95, "Negative": 0.05}, ...}, keyed by the parent's label or its full path "A>B". count = n numbered branches. Probabilities are numbers, decimal strings or fractions ("4/52"); one missing value in a branch set is filled with the rest of 1. Labels may contain $...$ TeX ("Disease$^c$"). |
| stageCounts | number[] | none | Counting shortcut: stage k has n_k numbered branches (e.g. [3, 2, 4]); names via stageNames. |
| alphabet | string | (string | number)[] | none | Words / strings / ordered selections: the labels offered at every stage (a list, or a string like "A-E", "HT", "a,b,c"); `length` stages. Combine with replacement, adjacentDistinct, forbid, probabilities or equallyLikely. |
| urn | object | none | Draws from an urn: {label: count}, e.g. {"Red": 5, "Blue": 3}. Branch probabilities are remaining/total after the earlier draws (exact fractions); `length` draws. |
| length | number | 2 | Number of stages for alphabet and urn trees (1-8). |
| replacement | boolean | true for alphabet, false for urn | Whether a drawn label stays available. alphabet with replacement false = ordered selection without repetition (n, n-1, ...). |
| adjacentDistinct | boolean | false | alphabet: consecutive labels must differ (history-dependent but even branching). |
| forbid | string[] | [] | alphabet: forbidden consecutive runs, e.g. ["11"] (no two consecutive 1s); tokens split by characters for one-character labels, else by commas or spaces. |
| probabilities | (number | string)[] | none | alphabet: one probability per label, the same at every stage (independent repeated trials, e.g. R 0.91, L 0.09). |
| equallyLikely | boolean | false | Every node splits its probability equally among its branches (fair coins, dice, random draws of distinct items). |
| stageNames | string[] | the stages' names | Column headings, one per stage (overrides stages[].name). |
| outcomes | string[] | words ("HHT") for one-character labels, else tuples "(a, b)" | Leaf labels in top-to-bottom order of the full tree, e.g. ["True Positive", "False Negative", ...]. |
| outcomesHeading | string | "Outcomes" | Heading of the outcome column (e.g. "Event"). |
| showOutcomes | boolean | true when outcomes are given or labels are one character or the tree is generated (alphabet, urn, stageCounts) | Show the outcome column. |
| event | string | string[] | none | Leaves preselected as an event (highlighted; their probabilities are added). Each entry is an outcome label ("TF"), a path ("Disease>Positive") or a branch label ("Positive" = every leaf through a Positive branch). |
| eventName | string | "event" | Name used in the readout, P(<eventName>) = ... |
| selected | string | none | Leaf whose path is highlighted and multiplied out at load (outcome label or path "R>R"). |
| reveal | string | "all" | Path products: "all" (every leaf), "selected" (only the selected leaf, written out as 0.91 × 0.91 = 0.8281; slide style), "hidden" (? until the learner clicks a leaf; use before an exercise) or "step" (Next leaf reveals them in order). |
| reverse | boolean | false | Two-stage probability trees: open in the Reversed view (second stage first, branches P(second) and P(first | second): Bayes). The Forward / Reversed toggle is shown whenever the tree can be reversed. |
| grow | boolean | false | Start from the root (or `depth` stages) and let the learner grow one stage at a time; node counts of ungrown stages show ?. |
| depth | number | 0 | grow: stages already grown at load. |
| editable | boolean | false | Sliders for every two-branch probability set (e.g. prevalence, P(Positive | Disease)); for stageCounts trees, − / + buttons per stage. |
| population | number | none | Natural frequencies: also show expected counts out of this many (node labels, a count column, and counts in the Bayes readout). |
| digits | number | 4 | Decimals for computed probabilities. |
| maxLeaves | number | 24 | Rows drawn before the tree is folded (big trees show ▸ nodes that open on click). |
| maxBranches | number | 6 | Branches drawn per node; the rest are folded into a "+ k more" stub. |
| showLevelCounts | boolean | true for trees without probabilities | Show the leaf count (as a product when the branching is even) and the table of branches per node and nodes per stage. |
| clickMode | string | "path" | What a leaf click does at load: "path" (trace and multiply) or "event" (add / remove the leaf from the event). |
| format | string | "auto" | Number format: "auto" (fractions when any probability is a fraction, urn or equallyLikely), "decimal" or "fraction". |
| controls | string[] | all controls shown | Registry ids of the hideable controls and text to show (see `controls` in this file): view.reversed (Forward / Reversed toggle), click.event (Build an event), readout.path-notation (P(A ∩ B) = P(A) · P(B | A)), readout.stage-independence, readout.stage-dependence, readout.product-rule (leaf count as a product). Core controls always show. Absent = everything. Fitted per page by tooling (component_scopes.py fit-nodes), not by hand. |