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

PropTypeDefaultDescription
titlestring"Probability tree" or "Decision tree"Title bar text.
stagesobject[]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$").
stageCountsnumber[]noneCounting shortcut: stage k has n_k numbered branches (e.g. [3, 2, 4]); names via stageNames.
alphabetstring | (string | number)[]noneWords / 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.
urnobjectnoneDraws from an urn: {label: count}, e.g. {"Red": 5, "Blue": 3}. Branch probabilities are remaining/total after the earlier draws (exact fractions); `length` draws.
lengthnumber2Number of stages for alphabet and urn trees (1-8).
replacementbooleantrue for alphabet, false for urnWhether a drawn label stays available. alphabet with replacement false = ordered selection without repetition (n, n-1, ...).
adjacentDistinctbooleanfalsealphabet: consecutive labels must differ (history-dependent but even branching).
forbidstring[][]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)[]nonealphabet: one probability per label, the same at every stage (independent repeated trials, e.g. R 0.91, L 0.09).
equallyLikelybooleanfalseEvery node splits its probability equally among its branches (fair coins, dice, random draws of distinct items).
stageNamesstring[]the stages' namesColumn headings, one per stage (overrides stages[].name).
outcomesstring[]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", ...].
outcomesHeadingstring"Outcomes"Heading of the outcome column (e.g. "Event").
showOutcomesbooleantrue when outcomes are given or labels are one character or the tree is generated (alphabet, urn, stageCounts)Show the outcome column.
eventstring | string[]noneLeaves 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).
eventNamestring"event"Name used in the readout, P(<eventName>) = ...
selectedstringnoneLeaf whose path is highlighted and multiplied out at load (outcome label or path "R>R").
revealstring"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).
reversebooleanfalseTwo-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.
growbooleanfalseStart from the root (or `depth` stages) and let the learner grow one stage at a time; node counts of ungrown stages show ?.
depthnumber0grow: stages already grown at load.
editablebooleanfalseSliders for every two-branch probability set (e.g. prevalence, P(Positive | Disease)); for stageCounts trees, − / + buttons per stage.
populationnumbernoneNatural frequencies: also show expected counts out of this many (node labels, a count column, and counts in the Bayes readout).
digitsnumber4Decimals for computed probabilities.
maxLeavesnumber24Rows drawn before the tree is folded (big trees show ▸ nodes that open on click).
maxBranchesnumber6Branches drawn per node; the rest are folded into a "+ k more" stub.
showLevelCountsbooleantrue for trees without probabilitiesShow the leaf count (as a product when the branching is even) and the table of branches per node and nodes per stage.
clickModestring"path"What a leaf click does at load: "path" (trace and multiply) or "event" (add / remove the leaf from the event).
formatstring"auto"Number format: "auto" (fractions when any probability is a fraction, urn or equallyLikely), "decimal" or "fraction".
controlsstring[]all controls shownRegistry 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.