|
| 1 | +import { g } from "../../util"; |
| 2 | + |
1 | 3 | const ovr = ( |
2 | 4 | players: { |
3 | 5 | ratings: { |
@@ -45,18 +47,40 @@ const ovr = ( |
45 | 47 | b = -0.1609; |
46 | 48 | k = 102.98; |
47 | 49 | } |
48 | | - const predictedMOV = |
49 | | - -k + |
50 | | - a * Math.exp(b * 0) * ratings[0] + |
51 | | - a * Math.exp(b * 1) * ratings[1] + |
52 | | - a * Math.exp(b * 2) * ratings[2] + |
53 | | - a * Math.exp(b * 3) * ratings[3] + |
54 | | - a * Math.exp(b * 4) * ratings[4] + |
55 | | - a * Math.exp(b * 5) * ratings[5] + |
56 | | - a * Math.exp(b * 6) * ratings[6] + |
57 | | - a * Math.exp(b * 7) * ratings[7] + |
58 | | - a * Math.exp(b * 8) * ratings[8] + |
59 | | - a * Math.exp(b * 9) * ratings[9]; |
| 50 | + |
| 51 | + const numPlayersOnCourt = g.get("numPlayersOnCourt"); |
| 52 | + let predictedMOV; |
| 53 | + if (numPlayersOnCourt >= 5) { |
| 54 | + predictedMOV = |
| 55 | + -k + |
| 56 | + a * Math.exp(b * 0) * ratings[0] + |
| 57 | + a * Math.exp(b * 1) * ratings[1] + |
| 58 | + a * Math.exp(b * 2) * ratings[2] + |
| 59 | + a * Math.exp(b * 3) * ratings[3] + |
| 60 | + a * Math.exp(b * 4) * ratings[4] + |
| 61 | + a * Math.exp(b * 5) * ratings[5] + |
| 62 | + a * Math.exp(b * 6) * ratings[6] + |
| 63 | + a * Math.exp(b * 7) * ratings[7] + |
| 64 | + a * Math.exp(b * 8) * ratings[8] + |
| 65 | + a * Math.exp(b * 9) * ratings[9]; |
| 66 | + } else { |
| 67 | + predictedMOV = -k; |
| 68 | + |
| 69 | + let ratingsIndex = 0; |
| 70 | + for (let i = 0; i < numPlayersOnCourt; i++) { |
| 71 | + predictedMOV += a * Math.exp(b * i) * ratings[ratingsIndex]; |
| 72 | + ratingsIndex += 1; |
| 73 | + } |
| 74 | + |
| 75 | + // Skip the coefficients of the normal starters who are now bench players |
| 76 | + for (let i = 5; i < 10; i++) { |
| 77 | + predictedMOV += a * Math.exp(b * i) * ratings[ratingsIndex]; |
| 78 | + ratingsIndex += 1; |
| 79 | + } |
| 80 | + |
| 81 | + // Rough estimates to keep ovr on 0-100 scale |
| 82 | + predictedMOV += (60 * (5 - numPlayersOnCourt)) / 5; |
| 83 | + } |
60 | 84 |
|
61 | 85 | if (rating) { |
62 | 86 | // In this case, we're ultimately using the value to compute a rank or some other relative score, so we don't care about the scale |
|
0 commit comments