Template talk:Winning percentage
This template does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||
|
Template:Winning percentage is permanently protected from editing because it is a heavily used or highly visible template. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify an administrator or template editor to make the requested edit. Usually, any contributor may edit the template's documentation to add usage notes or categories.
Any contributor may edit the template's sandbox. Functionality of the template can be checked using test cases. |
Divide by zero error
[edit]If the wins and losses are both 0, then the template will return a divide by zero error. I addressed it somewhat at {{CBB Standings Entry}}. Maybe something like that could be done here. — X96lee15 (talk) 22:16, 3 December 2009 (UTC)
- Thanks for pointing that out. I didn't even test that scenario. Should be fixed. I added this case to the examples in the documentation.—NMajdan•talk 22:49, 3 December 2009 (UTC)
.000
[edit]Please explain to me why ".000" isn't technically correct.—NMajdan•talk 03:42, 4 December 2009 (UTC)
- The result of a divide by 0 is undefined (not .000). In my last edit though, I may have removed too much (which I think I've fixed but the WP servers seem to be lagging quite a bit) so that 0 win and 1 loss is reporting "dash" when that definitely should be ".000". I was just trying to fix the case of 0 wins and 0 losses. — X96lee15 (talk) 03:48, 4 December 2009 (UTC)
- Ok, that I'm ok with. Zero games, fine, em dash will work. I definitely had an issue with 0 wins, more than 0 losses or ties. But, I see you changed that. Thanks.—NMajdan•talk 03:51, 4 December 2009 (UTC)
4 or 5 decimals places
[edit]Can we add an optional parameter to display the percentage to 4 or 5 decimals places? That would help a great deal with breaking ties on a list like this: List of college football coaches with a .750 winning percentage. Thanks. Jweiss11 (talk) 10:51, 5 October 2010 (UTC)
division
[edit]Why does {{Winning percentage|100|50|3}} render as .663? and not .654, which is 100/153 (totals wins/total games)? hello, i'm a member | talk to me! 22:38, 1 November 2010 (UTC)
- Because 100 wins and 3 ties is computed as 101.5 wins (1/2 wins per tie). 101.5/153 == .663. — X96lee15 (talk) 02:59, 2 November 2010 (UTC)
- Thanks. I'll put that in the documentation so others won't be as confused. hello, i'm a member | talk to me! 00:50, 7 November 2010 (UTC)
much later comment
[edit]Just discovered this template during a reviewing exercise. Note that the above computation is correct by current NFL rules. Prior to 1972, the NFL did not figure ties in at all. Thus, in 1967, the Colts and Rams each had a record of 11-1-2, which was calculated as .917 (i.e., 11/12), rather than as .857 (i.e., 12/14). So if you want to use this template, you need to make sure that (a) the league table you're calculating uses this approach, and (b) that you are calculating correctly for time in history you're discussing. StevenJ81 (talk) 19:39, 4 November 2013 (UTC)
- Perhaps we add a
compute_ties=
parameter that ignores ties when set to "y". Or something like that. — X96lee15 (talk) 21:03, 4 November 2013 (UTC)
Automatically create record
[edit]Is it possible to edit this so that instead of just the percentage, a flag could be added (by default, no, for backwards compatibility) so that the win-loss record would automatically proceed the percentage? For example, {{Winning percentage|20|10|record=y}} would display 20–10 (.667)
(i.e., include the win-loss-tie record, not just percentage). This feature would seem to prevent typos and generally make life easier when adding and updating records. If this template already exists, and I just don't know it, could you point me in that direction? Thanks! 70.208.147.170 (talk) 04:46, 13 October 2014 (UTC)
Parameter to specify precision
[edit]I would love to use this template for tennis records, but in articles like ATP World Tour records it is standard to use 2 decimals for precision instead of 3 (e.g., 66.67% instead of 66.667%). Is it possible to add that option to this template? Thanks a lot, Gap9551 (talk) 17:58, 21 November 2015 (UTC)
Explain formula
[edit]To clarify what X96lee15 says, the formula is:
winning percentage = (wins + (ties ÷ 2)) ÷ (wins + losses + ties)
Which gives (916 + (36 ÷ 2)) ÷ (916 + 329 + 36 ) = 0.729
and indeed
{{Winning percentage|916|329|36}} = .729
I do not know how to get this formula into the "tool tip" or other comment place where it is obvious. I dug, and searched, and found X96lee15 comment on a different page, and then came here as the last place. Could someone who knows more than me, put this formula into the tool tip?
I am aware that it is a struggle to get the computer to handle the "edge" cases, i.e. when one or more of those numbers is zero. But I assume a reader knowledgeable enough to understand the formula, also is knowledgeable enough to understand zero. Nick Beeson (talk) 13:46, 2 January 2016 (UTC)
Tie error with no losses?
[edit]I was just over on List of NCAA Division I FBS football bowl records and I noticed that New Mexico State's 3-0-1 record comes out as 1.000 instead of .875 as would be expected. I confirmed that it wasn't a typo, that the tie was properly placed in the page. I think there might be an error where if wins > 0 and losses = 0, it automatically returns "1.000" before checking for ties. I want to see what happens in the strange case of a team with more ties than wins, but no losses.
{{Winning percentage|2|0|4}} = .667
...Yeah, that's what I thought. I'll see if I can fix this myself, but I'm not confident in my abilities. Cyberchao X (talk) 21:44, 10 January 2018 (UTC)
Okay, it looks like I fixed it myself after all. The problem was exactly what I thought--it was coded to automatically return "1.000" if wins were greater than 0 and losses were 0, with no reference to whether the parameter for ties was present. It should work properly now. Cyberchao X (talk) 22:16, 10 January 2018 (UTC)
Allow commas in wins/losses/ties?
[edit]Would it be possible to allow for commas in the wins/losses/ties parameters? The numbers are easier to read with commas once you get into the thousands, but using them in this template breaks the winning percentage calculation due to unexpected punctuation. It would be great if there was a way for the percentage calculation function to ignore commas if editors use them in the other parameters. Thanks! WildCowboy (talk) 05:02, 9 March 2018 (UTC)
- @WildCowboy: Done—Bagumba (talk) 11:52, 28 May 2020 (UTC)
Template-protected edit request on 25 June 2018
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Add the "compute_ties=" parameter as mentioned here: Template talk:Winning percentage#much later comment. Currently working on Overwatch League articles where I would like to use {{Winpct}}, however it isn't possible as ties aren't valued/wouldn't be considered half-wins. Ideally would need the ability to omit ties in a similar fashion to that mentioned in the talk page. Would be useful in any scenarios where ties aren't valued, but still needed in the total.
Solution also seems simple enough (parameter can be changed to ignore_ties or whatever seems suitable):
|{{#ifeq:{{{leading_zero|}}}|y|0}}.{{padleft:{{#expr:({{{1}}}{{#if:{{{3|}}}| +({{{3}}}/2) }})/({{{1}}}+{{{2}}}{{#if:{{{3|}}}|+{{{3}}}}})*1000 round 0}}|3|0}}
to
|{{#ifeq:{{{leading_zero|}}}|y|0}}.{{padleft:{{#expr:({{{1}}}{{#if:{{{3|}}}| {{#ifeq:{{{omit_ties}}}|y|+0|+({{{3}}}/2)}} }})/({{{1}}}+{{{2}}}{{#if:{{{3|}}}|+{{{3}}}}})*1000 round 0}}|3|0}}
Wiki nV (talk) 23:01, 25 June 2018 (UTC)
- Not done: please make your requested changes to the template's sandbox first; see WP:TESTCASES. — Martin (MSGJ · talk) 22:13, 28 June 2018 (UTC)
- @MSGJ: Hi Jason, I edited two versions in the sandbox. The first version adds the "omit_ties" parameter and maintains the same test case results the current template generates. The second version adds the "omit_ties" parameter and achieves all the desired test case results, I only realised they're user added after so I'm not sure if you still want the template to cater for those. Wiki nV (talk) 01:12, 30 June 2018 (UTC)
- I've studied the code and still have no idea how it works. If you assure me you have fully tested the change and it works correctly then I will deploy. — Martin (MSGJ · talk) 07:09, 2 July 2018 (UTC)
- @MSGJ: Hi Jason, I edited two versions in the sandbox. The first version adds the "omit_ties" parameter and maintains the same test case results the current template generates. The second version adds the "omit_ties" parameter and achieves all the desired test case results, I only realised they're user added after so I'm not sure if you still want the template to cater for those. Wiki nV (talk) 01:12, 30 June 2018 (UTC)
- @MSGJ: Hi again, to hopefully keep everything as simple as possible I changed the sandbox template to only include the "ignore_ties" parameter addition as that's the functionality I wanted to add. Can confirm test case results output the same as the current live template.
- Currently when ties are included the Winning percentage is calculated where ties count as a ½ win, i.e.
- What the "ignore_ties" parameter hopes to achieve is the calculation when ties hold zero value and the equation is simply: wins divided by the total number of matches played, i.e.
- The only change now included is rewriting the (+ 0.5 * ties) part from
+({{{3}}}/2) to {{#ifeq:{{{ignore_ties}}}|y| |+({{{3}}}/2)}}
- Which is a simple if statement, so if the "ignore_ties" parameter is included (=y) do nothing, else retain the current (+ 0.5 * ties).
- Also, just a worth a note, the
|{{#ifeq:{{{record}}}|y|)
which you thought does nothing actually generates the closing bracket for when the "record" parameter is used e.g.,0–0–1 (.500) instead of 0–0–1 (.500
. It's also not my addition, it already exists in the live template. - Hope that covers everything. Cheerio. Wiki nV (talk) 11:01, 2 July 2018 (UTC)
- Okay I have deployed. Thank you for trying to explain — Martin (MSGJ · talk) 11:13, 2 July 2018 (UTC)
- @MSGJ: Many thanks. By the way, when you get a moment, if you give Template:Winning percentage/doc a quick glance and check it's satisfactory I would appreciate it. Figured at least one other person should review it. Cheerio. Wiki nV (talk) 12:09, 2 July 2018 (UTC)
- Okay I have deployed. Thank you for trying to explain — Martin (MSGJ · talk) 11:13, 2 July 2018 (UTC)
Template-protected edit request on 11 May 2019
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Change template call {{ifempty}} to {{if empty}} to avoid the redirect. That template is transcluded in over 20,000 articles through being called in this template; that unnecessary redirect has to be followed every time one of those articles is viewed. Colonies Chris (talk) 16:07, 11 May 2019 (UTC) Colonies Chris (talk) 16:07, 11 May 2019 (UTC)
- Done — xaosflux Talk 19:38, 13 May 2019 (UTC)
- Thanks, Colonies Chris (talk) 08:01, 14 May 2019 (UTC)
Template-protected edit request on 3 October 2022
[edit]This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Is it possible to make the template display percentages with the %
symbol instead of with a zero value 0.XY and that it would also display {{Winning percentage|0|0}}
as 0–0
instead of —
? Qwerty284651 (talk) 23:30, 3 October 2022 (UTC)
- Not done for now: please establish a consensus for this alteration before using the
{{edit template-protected}}
template. It is probably possible, but not reasonable. The template has behaved this way since 2009 (see talk sections above). 0/0 does not result in a percentage of 0%. Displaying "–" or "n/a" or something similar is appropriate. – Jonesey95 (talk) 22:42, 4 October 2022 (UTC)- So be it. Qwerty284651 (talk) 22:50, 4 October 2022 (UTC)
- One or more of the features you desire may be present in {{Percentage}}. – Jonesey95 (talk) 22:51, 4 October 2022 (UTC)
- @Jonesey95:
{{Percentage}}
Won't cut it. Till next time. Qwerty284651 (talk) 23:29, 4 October 2022 (UTC)
- @Jonesey95:
- One or more of the features you desire may be present in {{Percentage}}. – Jonesey95 (talk) 22:51, 4 October 2022 (UTC)
- So be it. Qwerty284651 (talk) 22:50, 4 October 2022 (UTC)
Edit request 3 June 2024
[edit]No change. Asking for guidance. How can I set the 1.000 to display as 1.00, i.e. limit it to 2 decimals? Is there a decimal customization param for that? Qwerty284651 (talk) 02:33, 3 June 2024 (UTC)
- According to the /doc page, "The result is displayed as a decimal point followed by three digits, as is standard in sports standings." So no, I don't see a param that would be able to alter from 3 to 2 decimal places. So sorry, editor Qwerty284651. And I would ask you to please only use {{TPER}} when you actually want to edit a subject page. If you want to seek editing help, then please use the {{Help}} or {{Admin help}} template. Thank you for your help with this! P.I. Ellsworth , ed. put'er there 09:17, 3 June 2024 (UTC)