Template:ConfidenceInterval: Difference between revisions

From HorizonXI Wiki
(Created page with "<includeonly><onlyinclude><!-- standard case: return an estimation of the 95% confidence interval -->{{#ifexpr: {{{1}}} > 3 and {{{1}}} < ({{{2}}} - 3) | +/- {{#expr: 100*(1.96 * (sqrt (({{{1}}} / {{{2}}}) * (1-({{{1}}} / {{{2}}})) / {{{2}}} ))) round {{{digits|2}}}}}<!-- -->|<!-- if less than three success registered, use "rule of 3" for the upper bound -->{{#ifexpr: {{{1}}} <= 3 and {{{1}}} >= 0 | + {{#expr: 100* 3/{{{2}}} round {{{digits|2}}}}}<!-- -->|<!-- if nearly...")
 
m (added trivial case of zero sample to return nothing at all)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly><onlyinclude><!--
<includeonly><onlyinclude><!--
If no sample at all, return nothing
-->{{#ifeq:{{{2}}}|0||<!--
standard case: return an estimation of the 95% confidence interval
standard case: return an estimation of the 95% confidence interval
-->{{#ifexpr: {{{1}}} > 3 and {{{1}}} < ({{{2}}} - 3) | +/- {{#expr: 100*(1.96 * (sqrt (({{{1}}} / {{{2}}}) * (1-({{{1}}} / {{{2}}})) / {{{2}}} ))) round {{{digits|2}}}}}<!--
-->{{#ifexpr: {{{1}}} > 3 and {{{1}}} < ({{{2}}} - 3) |+/-{{#expr: 100*(1.96 * (sqrt (({{{1}}} / {{{2}}}) * (1-({{{1}}} / {{{2}}})) / {{{2}}} ))) round {{{digits|1}}}}}<!--
-->|<!--
-->|<!--
if less than three success registered, use "rule of 3" for the upper bound
if less than three success registered, use "rule of 3" for the upper bound
-->{{#ifexpr: {{{1}}} <= 3 and {{{1}}} >= 0 | + {{#expr: 100* 3/{{{2}}} round {{{digits|2}}}}}<!--
-->{{#ifexpr: {{{1}}} <= 3 and {{{1}}} >= 0 |+/-{{#expr: 100* 3/{{{2}}} round {{{digits|1}}}}}<!--
-->|<!--
-->|<!--
if nearly all draws end in successes, use "rule of 3" for the lower bound
if nearly all draws end in successes, use "rule of 3" for the lower bound
-->{{#ifexpr: {{{1}}} >= ({{{2}}} - 3) and {{{1}}} <= {{{2}}} | - {{#expr: 100* 3/{{{2}}} round {{{digits|2}}}}}<!--
-->{{#ifexpr: {{{1}}} >= ({{{2}}} - 3) and {{{1}}} <= {{{2}}} |+/-{{#expr: 100* 3/{{{2}}} round {{{digits|1}}}}}<!--
-->|<!--
-->|<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
--></onlyinclude></includeonly>
-->}}</onlyinclude></includeonly>


==Usage==
==Usage==


Calculates the 95% confidence interval for inputs k successes on n total number of draws. Returns a percentage value without % sign with two digits (if more or less digits are desired, use the digits argument).  
Calculates the 95% confidence interval for inputs k successes on n total number of draws. Returns a percentage value without % sign with one decimal (if more or less digits are desired, use the digits argument).  


<pre>{{ConfidenceInterval|k|n}}</pre>
<pre>{{ConfidenceInterval|k|n}}</pre>


*50 success on 100 draws represents a success rate of ({{#expr: 100*(50/100)}} {{ConfidenceInterval|50|100}})%
*50 success on 100 draws represents a success rate of ({{#expr: 100*(50/100)}}{{ConfidenceInterval|50|100}})%
*250 success on 500 draws represents a success rate of ({{#expr: 100*(250/500)}} {{ConfidenceInterval|250|500}})%
*250 success on 500 draws represents a success rate of ({{#expr: 100*(250/500)}}{{ConfidenceInterval|250|500}})%
*50 success on 500 draws represents a success rate of ({{#expr: 100*(50/500)}} {{ConfidenceInterval|50|500|digits=5}})% (displaying up to 5 digits with the digits argument here).  
*50 success on 500 draws represents a success rate of ({{#expr: 100*(50/500)}}{{ConfidenceInterval|50|500|digits=5}})% (displaying up to 5 digits with the digits argument here).  
*100 success on 100 draws represents a success rate of ({{#expr: 100*(100/100)}} {{ConfidenceInterval|100|100}})%
*100 success on 100 draws represents a success rate of ({{#expr: 100*(100/100)}}{{ConfidenceInterval|100|100}})%
*0 success on 100 draws represents a success rate of ({{#expr: 100*(0/100)}} {{ConfidenceInterval|0|100}})%
*0 success on 100 draws represents a success rate of ({{#expr: 100*(0/100)}}{{ConfidenceInterval|0|100}})%
*4765 success on 4765 draws represents a success rate of ({{#expr: 100*(4765/4765)}} {{ConfidenceInterval|4765|4765}})%
*1 success on 100 draws represents a success rate of ({{#expr: 100*(1/100)}}{{ConfidenceInterval|1|100}})%
*0 success on 365 draws represents a success rate of ({{#expr: 100*(0/365)}} {{ConfidenceInterval|0|365}})%
*2 successes on 100 draws represents a success rate of ({{#expr: 100*(2/100)}}{{ConfidenceInterval|2|100}})%
*100 success on 10 draws represents a success rate of ({{#expr: 100*(100/10)}} {{ConfidenceInterval|100|10}})% (this is a case where the confidence interval makes no sense, thus it is not reported if k > n).
*3 successes on 100 draws represents a success rate of ({{#expr: 100*(3/100)}}{{ConfidenceInterval|3|100}})%
*4 successes on 100 draws represents a success rate of ({{#expr: 100*(4/100)}}{{ConfidenceInterval|4|100}})%
*4765 success on 4765 draws represents a success rate of ({{#expr: 100*(4765/4765)}}{{ConfidenceInterval|4765|4765}})%
*0 success on 365 draws represents a success rate of ({{#expr: 100*(0/365)}}{{ConfidenceInterval|0|365}})%
*100 success on 10 draws represents a success rate of ({{#expr: 100*(100/10)}}{{ConfidenceInterval|100|10}})% (this is a case where the confidence interval makes no sense, thus it is not reported if k > n).
 
*Trivial case of zero sized sample returns nothing at all:
<pre>{{ConfidenceInterval|0|0}}</pre>
{{ConfidenceInterval|0|0}}

Latest revision as of 20:46, 12 January 2024


Usage

Calculates the 95% confidence interval for inputs k successes on n total number of draws. Returns a percentage value without % sign with one decimal (if more or less digits are desired, use the digits argument).

{{ConfidenceInterval|k|n}}
  • 50 success on 100 draws represents a success rate of (50+/-9.8)%
  • 250 success on 500 draws represents a success rate of (50+/-4.4)%
  • 50 success on 500 draws represents a success rate of (10+/-2.62962)% (displaying up to 5 digits with the digits argument here).
  • 100 success on 100 draws represents a success rate of (100+/-3)%
  • 0 success on 100 draws represents a success rate of (0+/-3)%
  • 1 success on 100 draws represents a success rate of (1+/-3)%
  • 2 successes on 100 draws represents a success rate of (2+/-3)%
  • 3 successes on 100 draws represents a success rate of (3+/-3)%
  • 4 successes on 100 draws represents a success rate of (4+/-3.8)%
  • 4765 success on 4765 draws represents a success rate of (100+/-0.1)%
  • 0 success on 365 draws represents a success rate of (0+/-0.8)%
  • 100 success on 10 draws represents a success rate of (1000)% (this is a case where the confidence interval makes no sense, thus it is not reported if k > n).
  • Trivial case of zero sized sample returns nothing at all:
{{ConfidenceInterval|0|0}}