틀:Chance/doc
A standardized way of probability presentation.
Usage
{{ chance | <fraction> | <digit to round to> (optional) | pad = y/yes (optional) | reduce = n/no (optional) | mode = f/p (optional) }}
- First unnamed parameter
The fraction of chance. e.g. 1/250
, 4/100
. It does not need to be an irreducible fraction, the template will reduce it if needed.
- Second unnamed parameter
Rounds off the percent number to a multiple of 1/10 raised to a power, with the exponent equal to this number. Default value is 2
.
- pad
If set, when the actual number of digits is less than the given value specified by the second unnamed parameter, it will pad the percent number with zeros to that length.
- reduce
Prevents automatic reduction of the fraction.
- mode
If set to f, only output fractal part; if set to p, only output percent part.
Example
Code | Result |
---|---|
{{chance|1/100}} |
|
{{chance|1 in 100}} |
|
{{chance|1 in 1,000}} |
|
{{chance|1/2500}} |
|
{{chance|1/100|pad=y}} |
|
{{chance|1/2500|4|pad=y}} |
|
{{chance|1/7}} |
|
{{chance|1/7|4}} |
|
{{chance|84/1000}} |
|
{{chance|84/1000|reduce=n}} |
|
{{chance|49/11250}} |
|
{{chance|1/2500|mode=f}} |
|
{{chance|1/2500|mode=p}} |
Options
This template supports options through {{options}} template. All valid options are listed below, see {{options}} for usage and other infomation.
See Template:chance/initOptions for the initial options setting of this template.
Name | Alias | Initial Value | Value Mapping[1] | Note |
---|---|---|---|---|
precision | dec | 2 | As Unnamed parameter 2 | |
pad | (empty) | yes → y on → y n → (empty) no → (empty) off → (empty) | ||
reduce | (empty) | y → (empty) yes → (empty) on → (empty) no → n off → n | ||
mode | both |
- ↑ Values with mapping will be stored and loaded as mapped value. Other values without mapping will be stored and loaded as-is.
Example:
A: {{chance|84/1000}} {{options/set|chance|precision=4|pad=y|reduce=n}} B: {{chance|84/1000}} {{options/reset|chance}}
It will output:
A:
8.4*21/250 (8.4%)
B:
8.4000*84/1000 (8.4000%)