Reference · Rolls and exact odds
distributionOffunction
Every total a spec can make and its chance. Several kinds of dice are independent, so their totals are put together by convolution: every pair of totals, their chances multiplied. Worked out once for each spec, then remembered.
Import it
import { distributionOf } from "@johnmorrisdotca/korokoro";
Definition
function distributionOf(spec: RollSpec): Distribution
Parameters
| Name | Type | Description |
|---|---|---|
spec | RollSpec | Dice counts, sides, rules and modifier; omitted fields use the documented defaults. |
Returns
Distribution
Every total a spec can make and its chance. Several kinds of dice are independent, so their totals are put together by convolution: every pair of totals, their chances multiplied. Worked out once for each spec, then remembered.
Examples
import { distributionOf } from "@johnmorrisdotca/korokoro";
import { normalizeSpec } from "@johnmorrisdotca/korokoro";
const spec = normalizeSpec({ count: 2, sides: 6 });
const odds = distributionOf(spec);
console.log(odds.min, odds.max, odds.probabilities[7 - odds.min]);2 12 0.16666666666666666What it prints (run when this page was built)