Jump to content

Module:ProbabilityFormat/doc

From RiskiPedia
Revision as of 21:26, 2 September 2025 by Gavinandresen (talk | contribs) (Created page with "{{documentation}} == 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: <syntaxhighlight lang="wikitext"> {{#invoke:ProbabilityFormat|convert|probability|cutof...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation page for Module:ProbabilityFormat

Template:Documentation

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:

<syntaxhighlight lang="wikitext"> Error: Invalid probability </syntaxhighlight>

  • 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
no chance no chance
100% chance 100% chance
almost certain (more than 9 in 10) almost certain (more than 9 in 10)
about 7 in 10 about 7 in 10
about 1 in 100 about 1 in 100
almost zero chance (less than 1 in 1,000,000) almost zero chance (less than 1 in 1,000,000)
almost zero chance (less than 1 in 10,000) almost zero chance (less than 1 in 10,000)

See also