Module:ProbabilityFormat/doc
Appearance
This is the documentation page for Module:ProbabilityFormat
Purpose
This module provides functions to convert fractional probabilities (e.g. `0.01`) into human-friendly text strings such as:
- `"no chance"`
- `"100% chance"`
- `"about 1 in 100"`
- `"almost zero chance (less than 1 in 1,000,000)"`
It is designed for use in templates where probabilities need to be expressed in plain language.
Usage
Basic syntax:
{{#invoke:ProbabilityFormat|convert|probability|cutoff}}
probability
(required) — a number between `0` and `1`.cutoff
(optional) — probabilities smaller than this are treated as “almost zero chance.” Defaults to `1e-6` (1 in 1,000,000).
Parameters
probability
- The fractional probability, either as a number or string (e.g. `0.05`).
cutoff
- A fractional cutoff for “almost zero” reporting. For example, passing `1e-4` will show “less than 1 in 10,000.”
Examples
Input | Output |
---|---|
{{#invoke:ProbabilityFormat|convert|0}} |
no chance |
{{#invoke:ProbabilityFormat|convert|1}} |
100% chance |
{{#invoke:ProbabilityFormat|convert|0.95}} |
almost certain (more than 9 in 10) |
{{#invoke:ProbabilityFormat|convert|0.7}} |
about 7 in 10 |
{{#invoke:ProbabilityFormat|convert|0.01}} |
about 1 in 100 |
{{#invoke:ProbabilityFormat|convert|1e-8}} |
almost zero chance (less than 1 in 1,000,000) |
{{#invoke:ProbabilityFormat|convert|1e-5|1e-4}} |
almost zero chance (less than 1 in 10,000) |