<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Div Tiwari on Medium]]></title>
        <description><![CDATA[Stories by Div Tiwari on Medium]]></description>
        <link>https://medium.com/@cricketscience?source=rss-a2eb3180dcc6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0vXI56ynGJb8dSYOGvaEtA.jpeg</url>
            <title>Stories by Div Tiwari on Medium</title>
            <link>https://medium.com/@cricketscience?source=rss-a2eb3180dcc6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 10:32:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cricketscience/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Quantifying Risk-Reward tradeoff with aggression in Cricket]]></title>
            <link>https://medium.com/@cricketscience/quantifying-risk-reward-tradeoff-with-aggression-in-cricket-274c3ec822c4?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/274c3ec822c4</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cricket-analysis]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[mathematical-modeling]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Thu, 02 Jan 2025 23:02:59 GMT</pubDate>
            <atom:updated>2025-01-02T23:32:14.974Z</atom:updated>
            <content:encoded><![CDATA[<p>It is the final of the T20 World Cup. You get ready to face the next ball. Only three overs remain in the inning — this is the time to accelerate. But your team is down seven wickets and you are the last proper batter remaining. If you get out, your teammates probably won’t add many more runs. What do you do? Do you go for the big shots to score more runs at the risk of getting out? Or do you stay cautious for a few more deliveries?</p><p>Sport is often about intuiting risk and reward. In this post, I will apply mathematics to understand that trade-off for cricket.</p><h3>The Motivation</h3><p>In <a href="https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-ii-implementing-berex-26d45e10ffa2">this post</a>, I showed contour plots of the expected total score for any given Average and Strike Rate (or Average and Economy rate for bowlers), derived using my BEREX model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*vEQE0rTO-XckCPJyBdKafg.png" /><figcaption>BEREX mean scores for 50-over innings</figcaption></figure><p>These allow us to quantify the relative importance of both those metrics. But there’s more — <em>of course</em> you would try to maximize both your Average and Strike Rate as a batter. The problem is that if you try to increase one, it is quite likely that the other would drop. A tradeoff.</p><p>What might that tradeoff curve look like? In other words, <strong>how does Average change with changes to Strike Rate?</strong></p><p>I started comparing statistics of batters for the various forms of cricket. I had expected Test averages to be highest, T20 averages to be lowest, and ODIs in between — in the reverse order of strike rates. More risk (fewer average runs) for more reward (faster scoring). But for many players, this was not the case. In fact, even aggregate ODI batting averages are often higher than Test batting averages! It seemed as if one could increase their reward with lesser risk. How could this be?</p><p>It turns out I had been asking the wrong question.</p><p>The inverted metric for risk should not have been the Average (runs per dismissal) but instead <em>bpd</em> (balls per dismissal). The inverse of <em>bpd</em> is the simply the probability of dismissal.</p><h3>The Model</h3><p>The <strong>Risk Elasticity Curve</strong> is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/147/1*HpgfXT-odVxV9O37fgM2uQ.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xFIy5YmIU-aRum5GBbCKLw.png" /><figcaption>Balls per dismissal (bpd) and runs per ball (sr) show an exponential relationship; plotted data is for Test, ODI, T20I, and T10 League from 2016 to 2023</figcaption></figure><p>This shows that <em>bpd</em> decreases exponentially with increased scoring rates across cricket as a whole. We can envision similar curves for individual teams or players — those will have different parameters, of course.</p><p>We can use this relationship to model the predicted Average as a function of scoring rate, since</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*SJxebiH1YzGD9ZSuGpphXA.gif" /></figure><p>The resulting curve peaks at a scoring rate of around 0.8 runs per ball i.e. a Strike Rate of 80. This matches up well with real-life data, where the overall ODI average is around 32 compared to the Test average of roughly 30 for Test-playing nations in the last 5 years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMsEOPOFxol2C54osvcuMQ.png" /><figcaption>The Risk Elasticity Curve predicts a relationship between Average and Strike Rate</figcaption></figure><h4>A Note on Model Selection</h4><p>I use an exponential fit to model the relationship between <em>bpd</em> and <em>sr</em> in the Risk Elasticity Curve. Back in 2020, I had four equation candidates for the model:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*Ognfx-Osq5j5FzYGrsJS7A.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/152/1*NN72E2Ueg3OWBUsG56GEag.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*pbQ-WnzTxkM_SAJZ3Qbeow.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/224/1*2DKl7w54Uc_-yKKT9RcbMw.gif" /></figure><p>Each of these results in a decent numerical fit to the data. This situation isn’t uncommon in Data Science. So how does one decide which model to use?</p><p>I tested the predictions of the candidate models and discovered conceptual issues with the first three. One, their best-fit coefficients imply an infinite value for <em>bpd</em> (i.e. zero probability of dismissal) at low scoring rates. Two, the Inverse and Rational models predict a nearly invariant Average of around 30, and the Linear probability model predicts a monotonically decreasing Average with increasing Strike Rate that never drops below about 25.</p><p>The Exponential model passed both these sanity checks —it outputs a small probability of dismissal even if not trying to score runs and implies Averages that align with empirical data.</p><h3>The Implications</h3><p><strong>Combine the Risk Elasticity Curve with BEREX to identify a ‘sweet spot’ to balance risk and reward. </strong>In limited-over formats, teams often run out of balls to play before they run out of wickets, so it is perfectly rational to increase Strike Rates at the cost of reduced Averages. BEREX adapts to this since its output contours change based on the the number of overs available. More on this in a future article.</p><p>If you want to maximize runs scored <em>on average </em>and <em>without a limit on balls faced </em>(i.e. in Test cricket), you are probably best off targeting the peak Average at around 0.8 runs per ball, or 4.8 runs per over. This is much higher than typical Test scoring, which hovers around 3.2 runs per over.</p><p>The England Cricket Team did this as part of their ‘Bazball’ strategy starting in 2022. I built this model in 2020, so England’s successes were an exciting validation of my prediction.</p><p>There is a catch. Maximizing runs <em>on average</em> does not mean you always score more. Increased scoring rates come with increased probabilities of dismissal, which increases the risk of being all-out for a lower score. That is indeed what happened with England’s Bazball approach.</p><p>To conclude, let’s go back to the hypothetical that kicked off this article. It is the final of the T20 World Cup. You get ready to face the next ball. How should you play?</p><p>It’s simple. You should use the Risk Elasticity Curve to estimate dismissal probability across a range of possible scoring rates, then optimize for projected scores in the remaining overs using the Bernoulli distributions generated by BEREX. Or you could just go with your gut.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=274c3ec822c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pythagorean Expectation: A Guide to Estimating Win Probabilities in any Sport]]></title>
            <link>https://medium.com/@cricketscience/pythagorean-expectation-a-guide-to-estimating-win-probabilities-in-any-sport-c470280381bc?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c470280381bc</guid>
            <category><![CDATA[cricket-analysis]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sabermetrics]]></category>
            <category><![CDATA[cricket]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Mon, 19 Dec 2022 02:09:48 GMT</pubDate>
            <atom:updated>2022-12-20T04:57:30.747Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Pythagorean expectation </strong>is a statistical model commonly used in baseball to estimate a team’s expected winning percentage based on their runs scored and runs allowed. It was initially developed by Bill James, a pioneer in the field of baseball analytics (aka Sabermetrics), and has since become a widely accepted tool in the sport for evaluating team performance.</p><p>However, the application of Pythagorean expectation is not limited to just baseball. In fact, it can be generalized to estimate win probabilities in any sport where the final score is determined by the difference between two teams’ points or goals. This includes sports such as basketball, hockey, soccer, and many others. With some caveats, it can also be applied to cricket.</p><p>In this post, we will explore the concept of Pythagorean expectation and how it can be applied to estimate win probabilities in any sport. In the spirit of sensible data science, I will present a mathematical derivation followed by a full example for data from ODI and T20 cricket. By the end of this post, you should have an understanding of how to use Pythagorean expectation to make informed predictions of the expected win percentage for sports teams.</p><h3>The Idea</h3><p>Here is the original formula, which holds for baseball:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*-V9JK6uiGJIw_G2ca4DkBg.png" /></figure><p>The exponent of 2 is what what lends this model its name — it is reminiscent of Pythagoras’ theorem, which relates the side lengths of a right-angled triangle.</p><p>A team whose actual win ratio is greater than this prediction has won more than it “should”, and vice-versa. We can arguably expect teams to ‘regress to the mean’ that is predicted over a long enough time. The appeal for applying the formula to the sport of your choice is obvious. The question is — does it still work for another sport?</p><p>I have good news and bad news. The bad news is that the formula shown above is a terribly poor predictor for a different sport like cricket. The good news is that it can be ‘fixed’ by simply changing the exponent. The question now is — how do we calculate the correct exponent for another sport?</p><h3>The Math</h3><p>Here, I will derive an equation that gives us the exponent to use in the Pythagorean expectation formula for a different sport. <strong>This section is optional</strong>; I recognize that not all share my enthusiasm for mathematics.</p><p>Assume that <em>p</em> is the exponent that correctly predicts the Win Ratio. I will use <em>R</em> to denote <em>Runs scored </em>and <em>R_A </em>for <em>Runs allowed</em>. We have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*ZOrmDEWfpOUlAbVXvPYgKA.png" /></figure><p>Win Ratio is Wins/(Wins + Losses). Using <em>W</em> and <em>L</em> for <em>Wins</em> and <em>Losses</em>, respectively, a series of simple manipulations gives us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*pQH6jxtPkxgGDbfm_gmtEg.png" /></figure><p>The ratio of losses-to-wins has a power law relationship with the ratio of runs allowed-to-runs scored. Invert the equality so it use the more common wins-to-losses ratio and then take the logarithm:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/235/1*pR_Xz3olykx7a-QQGnTqpA.png" /></figure><p>There it is! <strong>The desired exponent <em>p</em> can be determined from a linear fit of two quantities, both of which we can calculate easily from data</strong>.</p><h3>The Data Analysis</h3><p>In this section, I will apply the mathematics above to derive a Pythagorean expectation model for limited-overs international cricket, i.e. the ODI and T20I formats of cricket. This will be a three-step process:</p><ol><li>Data Wrangling — create a suitable dataset</li><li>Model fitting — fit the data to the model derived above to determine the exponent <em>p</em></li><li>Assessment — evaluate how good the models’ predictions are</li></ol><p>I’ve used MATLAB for this process and for creating the plots shown below.</p><h4>Data Wrangling</h4><p>Using international cricket data presents challenges, such as:</p><ul><li>There is no ‘every team plays every other team’ league, which can introduce bias in the dataset. An associate member of ICC like Oman would rarely, if ever, play a team like India or Australia.</li><li>Teams change over a course of time, and so does their corresponding data. For example, Afghanistan has become much better in recent years than it used to be. Their data from 2012 shouldn’t be merged with that from 2022.</li></ul><p>To get around the first one, I limit the dataset to matches involving the twelve full ICC members. For the second, we could split the dataset by calendar year. However, this can leave very few matches played by individual teams so the win-loss ratio becomes prone to statistical noise. So I split the T20I data in a period of two years (Jan 2021-Dec 2022) and then three year periods going back to 2008. This gave each team around 25–30 matches in each split. We end up with 60 data points in total.</p><p>For ODIs, I’ve used 4-year splits (this makes intuitive sense to me as the period between World Cups) and have 40 data points.</p><p>I excluded all ‘No Result’ matches, and Ties count 0.5 to both Wins and Losses.</p><h4>Model fitting</h4><p>Our model (derived above) is linear with just one coefficient, of the form <em>y = p*x</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/1*CS8ltXUkYnOrWYxmjT0RLA.png" /></figure><p>Here is the log-log plot of the runs scored-runs conceded ratios and win-loss ratios for T20Is, and the model fit statistics:</p><figure><img alt="Scatterplot estimating the Pythagorean exponent for T20I, showing a best-fit line with a slope of 8.3" src="https://cdn-images-1.medium.com/max/1024/1*T9OnoSzQ5-nkUUiqTueC8g.png" /></figure><pre>Linear model:<br>     f(x) = p*x<br>Coefficient (with 95% confidence bounds):<br>        p = 8.305  (6.813, 9.798)<br><br>Goodness of fit:<br>  SSE: 9.269<br>  R-square: 0.6774<br>  Adjusted R-square: 0.6774<br>  RMSE: 0.3964</pre><p>The same for ODIs:</p><figure><img alt="Scatterplot estimating the Pythagorean exponent for ODI, showing a best-fit line with a slope of 11.1" src="https://cdn-images-1.medium.com/max/1024/1*JRFFJI73SsCSgisceurGsg.png" /></figure><pre>Linear model:<br>     f(x) = p*x<br>Coefficient (with 95% confidence bounds):<br>        p =       11.14  (9.732, 12.54)<br><br>Goodness of fit:<br>  SSE: 6.025<br>  R-square: 0.8587<br>  Adjusted R-square: 0.8587<br>  RMSE: 0.3931</pre><h4>Assessment</h4><p>Eyeballing the best-fit plots and the R-square values show that we have quite good models. It is best to convert the predictions back to a metric we are familiar with (in this case the Win %) and perhaps do some statistical analysis of the residuals (the difference between the predicted and actual value for each datapoint).</p><p>Here are the Predicted vs Actual Win % plots for T20I and ODI, along with a <em>y = x</em> line:</p><figure><img alt="Scatterplot assessing the Pythagorean prediction for T20I" src="https://cdn-images-1.medium.com/max/1024/1*PRhDdkgG_a6aa7NgeS2FBQ.png" /></figure><figure><img alt="Scatterplot assessing the Pythagorean prediction for ODI" src="https://cdn-images-1.medium.com/max/1005/1*DItZL1Utr9VR831PJN1Ykg.png" /></figure><p>I am quite happy with these predictions! Most predictions are no more than 0.10 from the actual value (10% in terms of Win% instead of Win Ratio). The RMS (root mean square) of the residuals is 0.087 for T20I and 0.067 for ODI.</p><h3>Closing Thoughts</h3><p>We introduced the Pythagorean expectation formula used in baseball analytics and derived how it can be generalized to other sports. We applied that to construct Pythagorean expectation models for T20I and ODI cricket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*JA0L6ih2AcE8UKg5EJqygw.png" /></figure><p>As good answers often do, this may have raised some more questions in your mind. Why are the exponent values what they are? What does it mean for the value to be bigger (or smaller)? In what other ways can we use this model? Are there other simple models for predicting Win% in cricket? I invite you to share your thoughts in the comments. I plan to explore these questions in later posts.</p><p>If you liked this post, you may also enjoy <a href="https://medium.com/@cricketscience">my other posts</a> on data science applied to cricket (and sports in general).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c470280381bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Spoke to an Astronaut about Cricket (and Probability Distributions)]]></title>
            <link>https://medium.com/@cricketscience/i-spoke-to-an-astronaut-about-cricket-and-probability-distributions-2f0713c29121?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f0713c29121</guid>
            <category><![CDATA[cricket-analysis]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Fri, 26 Aug 2022 00:15:22 GMT</pubDate>
            <atom:updated>2022-08-26T00:15:22.823Z</atom:updated>
            <content:encoded><![CDATA[<p>A wonderful perk of working at <a href="https://www.mathworks.com/">MathWorks</a> — creators of MATLAB — is that I get to work with engineers and scientists in a variety of fields, ranging from robotics to neuroscience, finance to autonomous driving (and more in between). One such collaboration was with an astronaut turned researcher, whom I’ll call Prof. Astronaut. This is the story of how we got to talking about cricket. Through that, I’ll also share the importance of choosing the right kind of probability distribution and answer this simple question —<strong> what distribution best models the batting strike rates of players in a league?</strong></p><h3>If the shoe fits, question it…</h3><p>Prof. Astronaut’s lab was trying to predict individuals’ susceptibility to an infectious disease based on some simple physical tests. Such a model could prove helpful in selecting crew members for long duration spaceflight, such as for going to Mars and beyond.</p><p>The data the team had captured from one of their tests had a large proportion of zeros. They were applying something called zero-inflated negative binomial (ZINB) regression to this data. While this seemed to be a reasonable decision looking at the fitted model, I flagged this choice. Just because fitting a particular probability distribution <em>looks</em> right does not mean it is the right thing to do, speaking from statistical sensibilities. To understand why, here’s an example of a situation where ZINB regression does apply:</p><blockquote>The state wildlife biologists want to model how many fish are being caught by fishermen at a state park. Visitors are asked how long they stayed, how many people were in the group, were there children in the group and how many fish were caught. Some visitors do not fish, but there is no data on whether a person fished or not. Some visitors who did fish did not catch any fish so there are excess zeros in the data because of the people that did not fish. <em>[</em><a href="https://stats.oarc.ucla.edu/r/dae/zinb/"><em>From ucla.edu</em></a><em>]</em></blockquote><p>Aha! The underlying theory for ZINB suggests that the excess zeros are generated by a <em>separate process </em>from the count values and can be modeled independently. This accounts for the non-fishing visitors to the park in the example here. After understanding the data Prof. Astronaut’s lab had gathered, I realized this did not hold true for them. ZINB was out.</p><p><strong>The moral is to understand why we choose the probability distribution that we do</strong>. Such mathematical awareness is often what separates a capable data scientist from someone who can use data science tools.</p><h3>Prof. Astronaut ‘meets’ Rahul Dravid</h3><p>Our conversation then meanders towards databases and increasing the performance of queries. I have ideas in mind and need an example database to show these in action. Now, I had kept plenty of datasets handy for discussing machine learning. And had no shortage of computationally expensive routines to showcase cloud computing. But databases just weren’t a popular topic in my customer calls. As luck would have it, I happened to be working on one as a hobby — this was my ball-by-ball database of cricket.</p><p>I sample a randomly chosen segment of the ODI data and display it. I now pick a column value to filter by. Under ‘Striker’, I see a very familiar name. An Indian cricketing legend. Rahul Dravid.</p><p>Next, I show an efficient query to summarize Dravid’s batting filtered for a chosen time period and against some arbitrary selection of opposing teams. Prof. Astronaut asks clarifying questions. He says “Dravid” three or four times. I resist the temptation to wax poetic about the The Wall. It feels very amusing to be in the USA and hear an American — a former NASA astronaut, no less — say the name of a beloved cricketer from my childhood.</p><h3>How are Strike Rates distributed?</h3><p>Now for some cricket science. I used the database I mentioned above to create this histogram of career <a href="https://en.wikipedia.org/wiki/Strike_rate#Batting_strike_rate">batting strike-rates</a> across all seasons of the Indian Premier League:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*5P1IzwlnqJqRfsR30Jtjmw.png" /><figcaption>Distribution of batting strike-rates in IPL (qual. minimum 120 balls faced)</figcaption></figure><p>I included only the players who faced at least 120 balls. This is chosen to be big enough such that spurious/noisy data is excluded (for example, scoring a 4 off 1 ball for an absurd SR of 400), and small enough to ensure there is a reasonably large sample size of players. As an added bonus, 120 balls = 20 overs, the length of an inning in IPL, which just feels kinda neat.</p><p>I have three questions for you, reader:</p><ul><li>Who is the outlier to the right, approaching a SR of 180? Who is the one on the left below 80? Take a guess in the comments.</li><li>What probability distribution should we fit to this data? I’ll address this now.</li></ul><h3>Normal Distribution</h3><p>The <a href="https://en.wikipedia.org/wiki/Normal_distribution">Normal Distribution</a>, often informally called the bell curve, is perhaps the best known of distributions. It shows up in all sorts of places. It also seems like a solid choice. Lots of observations clustering near the center and getting less frequent as we move further away on either side? Check. Here is the best fit:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*Hg-z-LGdWY3uicKRe1ca7A.png" /><figcaption>Probability density function and best-fit of a normal distribution</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*mwmUMCYEKEuvSQjI" /></figure><p>Not bad, though it does underestimate the height of the central peak. Let’s move on to (what I believe is) the appropriate choice.</p><h3>Logistic Distribution</h3><p>I’ll start with the plot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*I59KHooxGOVwd34tiKltuQ.png" /><figcaption>Probability density function and best-fit of a logistic distribution</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*fNcZM8SHcpaQHGUx" /></figure><p>Much better! The <a href="https://en.wikipedia.org/wiki/Logistic_distribution">logistic distribution</a> looks similar to a normal distribution but has heavier tails. It is thus better able to account for the extremes and consequently for the central peak around the 120–130 range. Yet, remember the moral. Visual satisfaction is not enough justification for us.</p><h3>Why a Logistic Distribution?</h3><p>You may have already encountered logistic distributions. A common application is in logistic regression, used for modeling categorical dependent variables like yes-no choices or a choice of 3 or 4 possibilities. Its cumulative distribution function is the well-known ‘S-curve’ that can model population growth, diffusion of innovations, and infections in a pandemic. This latter curve has also been used as an activation function in neural networks (AKA deep learning).</p><p>The following section is a mathematical derivation of why a logistic distribution works for strike-rates. If you’re uninterested in the math, feel free to skip to the conclusion at the end, in bold.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/0*JeiKRLNXkn_qs7qt" /></figure><p>The fractional term in the summation is the ratio of the number of times the player scored <em>i</em> runs on a ball to the total number of balls faced. In other words, it is the <a href="https://en.wikipedia.org/wiki/Frequentist_probability">frequentist estimate</a> of their probability of scoring <em>i</em> runs on a ball.</p><p>Furthermore, I believe I can ignore the rare cases of <em>i=3</em> and <em>i=5</em>. To validate this claim, take a look at the outcome probabilities from all deliveries across all seasons of IPL so far:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*AAkDbytrg8R3TN38FSFNEA.png" /><figcaption>Frequentist probabilities of scoring a given number of runs off the bat per ball, rounded to nearest 0.1%</figcaption></figure><p>Indeed, excluding the possibility of scoring 3 or 5 runs off a ball will underestimate the strike-rate by under a percentage point on average. Notice that the first outcome in the table includes all cases with zero runs scored by the batsman (dot balls, wickets, byes, leg byes, and some no-balls). This gives us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*RZuvv-B87i4fEjpp" /></figure><p>This explains it! <strong>The batting strike-rate is a weighted sum of probabilities</strong>. These outcome probabilities are categorical dependent variables with a handful of possibilities, which as I mentioned at the start of this section, is exactly what logistic distributions apply to.</p><p>Another statistical factoid to emerge from this is that strike-rate calculation has effectively 4 <a href="https://en.wikipedia.org/wiki/Degrees_of_freedom_(statistics)">degrees of freedom</a>. The probability of scoring zero runs is determined automatically from these other four since probabilities must sum to one. This information can come in handy if we decide to do further statistical analyses into strike rates.</p><h3>Summary</h3><p>Statistical software and packages make it all too easy to slap any probability distribution onto your data and call it a day. The onus is on us to choose a distribution that accurately reflects the nature of the underlying data. The right choice is key to constructing statistically sound models for predictive or descriptive inference.</p><p>We showed that batting strike-rates are a weighted sum of a handful of probabilities and thus best modeled using a logistic distribution. Similarly, for my <a href="https://medium.com/@cricketscience/average-vs-strike-rate-part-i-introducing-berex-aa35585d152e">BEREX model combining Average and Strike Rate</a>, I modeled an inning as a Bernoulli process, and thus used a Binomial distribution.</p><p>As a final treat, here is an animation to better compare the two distributions we tried today. I wish you luck in your statistical modeling efforts!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*rbaOkhh_kJM6DaY2K_FsGQ.gif" /><figcaption>Comparison of the normal and logistic distribution fits on IPL SR data</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f0713c29121" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Do Sports Ratings Work?]]></title>
            <link>https://medium.com/@cricketscience/how-do-sports-ratings-work-9433f1e6c015?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9433f1e6c015</guid>
            <category><![CDATA[ratings]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[cricket-analysis]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Sun, 24 Jul 2022 21:30:07 GMT</pubDate>
            <atom:updated>2022-07-24T21:30:07.599Z</atom:updated>
            <content:encoded><![CDATA[<p>Ah, sports ratings —a topic for casual workplace chatter, fodder for heated debate, an attempt at objectively answering the eternal “who’s better?” questions, a proxy for truth or utterly rubbish (depending on who and when you ask). We can debate all day long whether it’s appropriate to simplify the complexities of a sports team’s or person’s skill into a single number. I feel quite divided on that topic myself. But the idea is just so <em>appealing.</em></p><p>Here, we’ll dive into the theoretical ideas that underlie a sports rating system. There will be some math as usual but nothing too crazy. This should give you a sense of how to interpret a rating and perhaps also prepare you to create rating systems of your own. Much of this article applies to any competitive arena, but I include an example analysis of the ICC Team Rankings for ODI cricket.</p><h3>Ratings are probabilities (kinda)</h3><p>Sports ratings are a measure of skill. Skill is tricky to measure. We can measure the number of runs, wickets, goals, or points a player/team scores or concedes. We know how often they win or lose as a result. The question any ratings system looks to (implicitly) answer is: how do you convert these observable quantities into a numerical proxy for skill?</p><p>I would argue that a rating should convey the capacity to win matches. The more likely you are to win, the more your rating should be. Winning, after all, is the ultimate goal of a sports match.</p><p>This means that I should be able to use ratings of two teams and calculate the probability of either team winning their match-up. By symmetry, this also means that there is a 50–50 chance of either outcome between two teams with identical ratings, if we ignore ties. If your rating is higher than your opponent’s, so is the probability of you winning. Of course, this may be subject to modification from details such as home advantage, form, etc. This simple idea is captured in this graph, representing the <a href="https://en.wikipedia.org/wiki/Elo_rating_system">Elo rating system</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N_GEJsB3YPHsOpnA.jpg" /><figcaption>Win probability is a function of the rating difference in the ELO system</figcaption></figure><h3>Ratings are oracles (kinda)</h3><p>Since a rating is an indicator of outcome probabilities, it essentially makes a ‘prediction’ for each upcoming match. This is a numerical estimate of what is expects will happen. For example, referring the graph above, if A has an ELO rating about 150 higher than B, the system predicts “A will beat B with probability 0.7”.</p><p>Is a ‘0.7 win for A’ possible? The actual outcome (again, ignoring ties) will either be A wins (1.0 for A) or B wins (0.0 for A). The difference between the prediction (0.7) and the outcome (1.0 or 0.0) tells us how ‘surprised’ the rating system was by the result. The more the surprise, the more the ratings typically need to be adjusted after the match. For example, if A wins, their ratings may update to subsequently predict a 0.71 probability of A winning against B. If the less likely outcome of B winning comes true, the extent of revision should be greater, such as 0.33 probability of B winning (and 0.67 for A). An imaginary “perfect” ratings system would never be surprised. Thus, that mythical system would never need to update the ratings. This last point is important and will come up later.</p><p>Such a system cannot (yet?) exist, of course. These ratings are based on past performance, and as any investor will tell you, past performance is not an indicator of future performance. Yet, at least in sports, it’s a pretty good indicator.</p><p>I want to note a caveat for the above example: a rating system could incorporate information about the margin of victory in points/runs. In that case, a win may be interpreted as ranging from a near-tie 0.5 to clear dominance as it approaches 1.0. In other words, there could be more than just the two outcomes. The idea of prediction versus surprise still holds.</p><h3>Case Study: ICC ODI Team Rankings</h3><p>To make more sense of ratings as probability predictors, it will help to study an example. I will use the ICC Men’s ODI Team Rankings. Here’s a snapshot of what the rankings are at the time of writing this post:</p><figure><img alt="ICC Men’s ODI Team Rankings table, as last updated on July 21, 2022" src="https://cdn-images-1.medium.com/max/1024/1*EZ-P7nlqJzO2rTtEZyZLIA.png" /></figure><p>Teams accumulate points in each match, which is divided by the number of matches played to give their rating (it’s rounded to the nearest integer). The system is designed with 100 being the rating for an ‘average international team’. That idea doesn’t seem to pan out, with 14 of the 20 teams rated below that mark, but in fairness the top 10 or so teams usually just play amongst each other.</p><p>The points are not related to runs/wickets but defined specifically for the ratings. They are awarded as shown in the figure below. The only information used is the outcome (win/loss/tie) and nothing more. You can read more about the <a href="https://en.wikipedia.org/wiki/ICC_Men%27s_ODI_Team_Rankings#Points_calculations">points calculations on Wikipedia</a>.</p><figure><img alt="Points allocation tables for ICC Team Rankings" src="https://cdn-images-1.medium.com/max/717/1*4kAO6ldvRavkgCWHxxbuoQ.png" /></figure><p>The points earned are added to the existing count, the number of matches is incremented, and the resulting updated rating then calculated. So for example, say Australia (rating 101) beats New Zealand (rating 128) in a game. Their ratings difference is less than 40, so the Aussies get 178 (=128+50) points while the Kiwis earn 51 (=101–50). Their respective ratings will be updated to 104 (~2503/24) and 123 (~1964/16). There is also a provision for giving less weight to older games —that aspect is not relevant for the upcoming calculations.</p><p>How does this translate to probabilities? Let’s bring on the math!</p><p>Consider a match-up between teams with ratings <em>R1</em> and <em>R2</em>. Let’s assume Team 1 wins with probability <em>p</em> and Team 2 wins otherwise, with probability <em>(1-p)</em>. We ignore the small chance of a tie for simplicity. How many points do the teams get?</p><h4>Case 1: |R1-R2|≤40</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/0*V5Nfw1aTzh9ETZ8D" /></figure><p>The expected points earned will thus be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/0*NKrYc37fhlHD3hoD" /></figure><p>As discussed above, the probability prediction made by the ratings is such as to make the expected change in ratings zero. This will happen if the expected points earned equals each team’s own rating. We can verify this easily enough (<em>R</em>: rating, <em>m</em>: matches, <em>P</em>: points earned in the <em>m+1</em>th match):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/0*uAQI7cOmQj2fbCs6" /></figure><p>Thus, we now set the Team 1’s expected points earned to its own rating in order to calculate the probability <em>p</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/0*HF4xfkGUj1kPZ1m3" /></figure><p>How delightfully simple! Start off with a win probability of 50% for equally rated teams, and add a percentage point for each rating point difference. Using Team 2’s expected points will give the same result by symmetry. Thus, for the above example of Australia (101) vs New Zealand (128), the ratings effectively predict NZ will win 77% of match-ups.</p><h4>Case 2: |R1-R2|&gt;40</h4><p>It is immediately obvious that the above calculation won’t always work. If India (109) play United States (27), do the ratings expect India to win 132% of the time!? This is why the points are earned differently when the ratings are very far apart. Interestingly, they are calculated using one’s <em>own</em> rating, not that of the opponent. So for United States (27), it doesn’t matter if they upset Afghanistan (69) or New Zealand (128) — they’ll get the same number of points.</p><p>A quick calculation from the stronger team’s perspective shows what this implies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/0*P9S_84I0Y4pg0vRD" /></figure><p>The rating cancels out entirely, leaving a constant predicted probability: 90% win for the stronger team and 10% win for the weaker one. This explains all the terribly low ratings towards the bottom of the ladder: if a weak team like PNG can upset a much stronger team, say, 3% of the time, the ratings consider it to underperform relative to the 10% bar it sets. This leads to ‘rating bleed’ for the bottom rated teams.</p><h4>Win probability graph</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*2PlXNrEX54OV06L6GpGSPw.png" /></figure><p>The ICC ratings system lacks the ‘smoothness’ of the ELO ratings win probability curve. This has disadvantages as we observed but its linearity is appealing due to simplicity.</p><h3>Grading Rating Systems</h3><p>We’ve learned that a sports ratings system is akin to a predictor. The ratings (and how ratings are updated) can be used to calculate their predicted match-up outcome probabilities. The difference between these predictions and reality tells us how ‘surprised’ a ratings system is. The less the surprise over a period of time, the better the <strong>predictive performance </strong>of that ratings system. This is the first and arguably most important measure for grading such systems.</p><p>If you have some data science experience, you know that one way to improve the predictive performance of a model is to increase <strong>dimensionality of input data </strong>i.e. train it with more input variables. Each additional piece of data contributes to making (or gives the illusion of making) more accurate predictions. Likewise, a ratings system that considers home advantage and winning margins in addition to just the result could reasonably be expected to outperform the ICC Team Rankings described above. However, such a choice results in a tradeoff between performance and simplicity. An overly complicated model can be unwieldy and generalize poorly.</p><p>Besides choosing the data to be used for a ratings system, there is the task of defining the mathematics that will govern the model. What is the implied win probability curve? How will ratings be updated? What is the ‘baseline’ rating for a new team? This stage often includes deciding values for some <strong>parameters</strong>. For example, the ICC Rankings we analyzed has a chosen rating difference of 40 where probability clips; the value of this clipping is set to 0.9/0.1; it also has a specific probability-to-rating slope of 0.01. Such parameters add ‘artificiality’ to the model, but can be carefully chosen to optimize the system’s performance for the given sport. <a href="https://www.espncricinfo.com/ci/content/page/429305.html">Net Run Rate </a>is an example of a parameter-free system though it has shortcomings as a ratings system.</p><p>These are three aspects on which we can grade and classify ratings systems. I find the idea of a parameter-free rating system rather appealing as it would be constructed exclusively from the data of the sport in question. <strong>Is it possible to construct a good parameter-free rating system for cricket?</strong> We’ll explore that in a future post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9433f1e6c015" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run Rate Hypothesis: How does scoring rate change with inning length?]]></title>
            <link>https://medium.com/@cricketscience/run-rate-hypothesis-how-does-scoring-rate-change-with-inning-length-d4197239ae5f?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4197239ae5f</guid>
            <category><![CDATA[complexity]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cricket-analysis]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[sports-analytics]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Sun, 29 May 2022 21:39:26 GMT</pubDate>
            <atom:updated>2022-05-29T21:53:22.370Z</atom:updated>
            <content:encoded><![CDATA[<p>A rather unique aspect of cricket compared to other professional sports is the variety of forms, ranging from five-day Test matches to 50-over ODIs, 20-over T20s, and more. Every cricket viewer knows these forms are very different beyond just the duration. Scoring is more aggressive the shorter the inning is.</p><p>The <strong>Run Rate Hypothesis</strong> is an approximate relationship that relates the inning length in a limited-over match with the expected run rate for that format of the game. I first became curious to develop such a formula with the popularization of T20Is and the Hong Kong Cricket Sixes Tournament. The latter is a 5-over variant, although with somewhat different rules than regular cricket and a smaller ground — thus emphasizing big hitting. The more recent Abu Dhabi T10 League involved international and near-international caliber players in a 10-over format, and thus generates yet another data point.</p><h3>The Idea</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/205/0*rV6g9JrL4MrFmrvP" /></figure><p>Where <em>N</em> is the number of overs per inning, and <em>k</em> is a constant.</p><p>How did I get here? We’ll begin by considering the overall run rates for Tests, ODIs, and T20Is in a 5 year period (2014 to 2019, inclusive):</p><p>Tests: 3.23<br>ODIs: 5.45<br>T20Is: 8.08</p><p>That period should give us sufficient data while also being brief enough to be representative of a time period. Scoring rates have changed substantially over the decades. I have chosen a period before the disruption from COVID. Additionally, it is limited to matches involving the twelve ICC full member teams. Such dataset selection choices are important in practical data science.</p><p>In five seasons of the HK Sixes tournament from 2009 to 2017, a total of 19,366 runs were scored off of 6,214 legal deliveries. This gives a run rate of about 18.70. In the first three seasons of Abu Dhabi T10 (2017 to 2019), there were 14,936 runs scored off of 7,873 balls at an average run rate of 11.38.</p><p>When I plotted the above formula on the run rate data for the four limited-over formats, I was blown away by the remarkable accuracy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*tGgqqykbpXCCvZJKVMyaDg.png" /></figure><p>The constant <em>k</em> in this fit is 38.54 and results in an <a href="https://en.wikipedia.org/wiki/Coefficient_of_determination">R-squared</a> of 0.9687. Excluding the 5-over datapoint (I’ll discuss below why we may choose to do so) changes <em>k</em> to 36.13 and yields a remarkable R-square value of 0.9984. I used MATLAB’s Curve Fitter app to perform the fit and create this plot, with the Trust-Region algorithms and robust regression using the LAR method. Feel free to ignore that last bit of technicality if it sounds unfamiliar — I’ve included it for anyone looking to reproduce these results.</p><h3>Selecting the Value of <em>k</em></h3><p>The constant <em>k</em> in the equation is called a constant of proportionality. Rearranging the equation shows how it can be calculated from the known quantities of the run rate and number of overs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/155/0*3SMJ0aVY-SjJxbv_" /></figure><p>Using the above data, the estimates for <em>k</em> from each format are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/0*GhvLiQooD0Ua0Vte" /></figure><p>Tantalizingly close! Hong Kong Super Sixes’ 5-over format seems to overscore compared to the other formats that cluster around 36–38. This could be explained by the fact that the format wasn’t played with the same cricketing rules as the others. For example, batsmen would be ‘retired’ once they reach or cross a score of 31*. The extra wicket-taking ball saved gives a slight run rate boost in the data. Furthermore, Hong Kong Cricket Ground is rather small. I believe these reasonably explain the higher <em>k</em>-value for the format.</p><h3>Generalizing to Test Cricket</h3><p>Can the hypothesis fit to test cricket? The challenge is that there isn’t a strict over limit in that format. Yet, we can define some reasonable analogues.</p><p>A Test match typically has about 90 overs per day over 5 days, for a total of 90*5 = 450 overs. Dividing by the number of innings per match (four) gives 112.5 overs on average (this is 112 overs and 3 balls). That predicts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/0*vsjifGPm3pQpK7fr" /></figure><p>Assuming a slightly higher number of 125 overs each for the 1st and 2nd inning gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/176/0*tDEhd9t8FRHTkPPN" /></figure><p>In 1st innings during the 2014–19 period, the average bowling strike rate (balls per wicket) was 66.3. For 10 wickets, that implies an average of 663 balls, or 110.5 overs. The average run rate in 1st innings in that period as 3.35. Thus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/0*hI3Qb9APVCNOxtGY" /></figure><h3>The Formula</h3><p>Across all formats, a value of around 36 seems to fit well for <em>k</em>. We now have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/0*eq-O3v2X8Xdv1hHN" /></figure><h3>Why Does This Work?</h3><p>It isn’t immediately obvious why this formula gives such accurate results. It also isn’t clear why such a relationship should even exist, as if there is a global cricketer conspiracy trying to modify scoring rates to fit an elegant looking mathematical expression.</p><p>When I first noticed this, I was very excited precisely <em>because</em> it’s so unexpected. This suggests that there might be an explanation to be discovered. Cricket is a <a href="https://en.wikipedia.org/wiki/Complex_system">complex system</a>, and many such systems demonstrate behavior explainable by simple underlying rules. For now, the equation remained a hypothesis and I was determined to explain it with a theory.</p><p>I’m happy to reveal that a couple of years ago, I cracked it! More on that in later stories.</p><h3>Closing Notes</h3><p>This simple formula can be used to predict the expected scoring rate for any inning duration. It is a compelling depiction of how aggression (thus scoring rates and total scores) adapt to longer innings, where conserving wickets becomes more important. If we double the number of overs, the hypothesis predicts that the scoring rate will fall to around 70% and the final score will thus be about 40% more. This is because</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/0*o47ntSxhp04IFFX5" /></figure><p>It is no secret that run rates have generally increased over the years, so it is natural to expect that the value of <em>k</em> changes over time. The constant would indeed be different for other leagues of players eg. Under-16 or Women’s, as well as have variations based on location. But I suspect the relationship as a whole remains. We may be glimpsing at some truth about the very structure of cricket.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4197239ae5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cricket Science — Average vs Strike Rate (Part III: Applying BEREX)]]></title>
            <link>https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-iii-applying-berex-84a8da629d84?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/84a8da629d84</guid>
            <category><![CDATA[sports-analytics]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[cricket-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Sat, 14 May 2022 23:11:21 GMT</pubDate>
            <atom:updated>2022-05-14T23:11:21.660Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cricket Science — Average vs Strike Rate (Part III: Applying BEREX)</h3><p>Here, I apply the BEREX (BErnoulli Run EXpectation) model to real-world cricket data. <a href="https://medium.com/@cricketscience/average-vs-strike-rate-part-i-introducing-berex-aa35585d152e">Read Part I</a> to learn about the idea, what motivated it, and its mathematical derivation. <a href="https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-ii-implementing-berex-26d45e10ffa2">In Part II</a>, I implemented the model in code and explored its theoretical predictions. Part I is heavy on math, while Part II uses visualizations to understand BEREX.</p><p>If there is one TL;DR takeaway you need from the two articles: BEREX calculates how many runs a team composed entirely of one player would score (or concede) against an average opposition of their era.</p><h3>ODIs, 2010 to present</h3><p>We begin by considering all ODIs in the period 2010 to present between any two ICC Full Members. This includes 12 teams. I now have a ball-by-ball database that I can query for data, and I intend to share it in the near future. If you’re looking to replicate this analysis, you could also obtain the summary data from a source like ESPNCricinfo’s Statsguru.</p><p>I have filtered the dataset to batsmen with at least 60 innings and bowlers with at least 60 wickets. This ensures we avoid ‘noisy’ data such as from inflated averages with very few innings. Why do I not use innings for bowlers as well? Because the number of wickets is the denominator when calculating bowling average (akin to innings for batsmen) and is thus the appropriate measure for ensuring sufficiency of sample size.</p><p>The BEREX function returns a mean and standard deviation. I have included those in the tables below. The batsmen are sorted by runs:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/525fcf174a3fd4faaba3dd4559557117/href">https://medium.com/media/525fcf174a3fd4faaba3dd4559557117/href</a></iframe><p>The bowlers are sorted by wickets:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/898de52ffa569b4a67874b7d00cd1e82/href">https://medium.com/media/898de52ffa569b4a67874b7d00cd1e82/href</a></iframe><p>Recall that a higher BEREX mean is better for batsmen but worse for bowlers. Take your time to browse through the data. We’ll talk about possible metrics of quality below. But first…</p><h3>T20Is, 2017 to 2022</h3><p>Let’s repeat the exercise for T20 Internationals. I’m using a shorter 5-year period (2017–01–01 to 2022–01–01) since this version of cricket is more rapidly evolving. It’s still limited to matches between two ICC Full Members but I’ve reduced the cutoff to 30 innings and 30 wickets, respectively. This still ends up excluding some notable players like Chris Gayle and Lasith Malinga.</p><p>Batsmen:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76ed78f4c60f3fc0bd9dc2075572157b/href">https://medium.com/media/76ed78f4c60f3fc0bd9dc2075572157b/href</a></iframe><p>Bowlers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2959a1784354f0ae6842fac0f2a2786/href">https://medium.com/media/d2959a1784354f0ae6842fac0f2a2786/href</a></iframe><h3>Z-scores and Percentiles</h3><p>As I mentioned in the <a href="https://medium.com/@cricketscience/why-cricket-science-127f6f4b0145">introductory post</a>, this blog series will also be an opportunity to learn statistics. These ideas are foundational to good data science. That’s what this section is about.</p><p>In the earlier parts, we learned that BEREX acts as a simple cricket inning simulator. It can use a Bernoulli process to generate a sample score. Creating thousands of such simulated scores will give us the sample Mean and Standard Deviation of the distribution of scores. We bypassed this approach by using an analytical approach to calculate the two numbers, but the results from the two approaches should converge.</p><p>This allows us to apply the <a href="https://en.wikipedia.org/wiki/Central_limit_theorem">Central Limit Theorem</a> — the <em>BerexMean</em> and <em>BerexSD </em>values are, respectively, the mean and standard deviation of a normal distribution. This in turn implies that we can use <a href="https://en.wikipedia.org/wiki/Standard_score">Z-scores</a> to calculate scores at a desired percentile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/79/0*ItKPD_Xws7-_qlBd" /></figure><p>For example, the 20th percentile of a normal distribution corresponds to a z-score of about -0.84. In other words, the BEREX model expects the ‘team of player clones’ to score less than that only 20% of the time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/162/0*teUN3fo6Cme_LwWC" /></figure><h3>BEREX Rankings</h3><p>BEREX has a very specific interpretation but does not produce an obvious one-dimensional ranking system of players. We can generate a ranking system from it, but it will necessarily introduce some subjectivity or arbitrariness in the assessment. This isn’t a flaw in the model; it is a consequence of mathematics. It is for this reason that I’m generally reluctant to create rankings that claim to be a definitive measure of quality — it’s simply too reductive.</p><p>For example, we can rank players by the BEREX means (descending for batsmen and increasing for bowlers). However, this arbitrarily chooses the 50th percentile of BEREX scores as our metric. Again, I’m not saying such a choice is <em>bad</em>, only that we should pick the percentile that meets our needs. I have found that low percentiles can often align with widespread opinion of player quality. Let’s see some results.</p><h4>Ranked by BEREX mean (50th %ile)</h4><figure><img alt="ODI Batsmen (2010–2022) ranked by BEREX mean" src="https://cdn-images-1.medium.com/max/1024/1*rhYUH9yFxBDKjqNadsna6A.png" /><figcaption>ODI Batsmen by BEREX 50%ile (2010–2022; Qual min 60 inns)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GOYhqLjlQKPf8PlVHmfTHA.png" /><figcaption>ODI Bowlers by BEREX 50%ile (2010–2022; Qual min 60 wkts)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2v-JxsbB6VIjLFzsz-2EEQ.png" /><figcaption>T20I Batsmen by BEREX 50%ile (2017–2022; Qual min 30 inns)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zO5H3g52uETwnBlcTPxSgQ.png" /><figcaption>T20I Bowlers by BEREX 50%ile (2017–2022; Qual min 30 wkts)</figcaption></figure><h4>Ranked by BEREX 10%ile</h4><p>The above rankings may be controversial. For example, where is Virat Kohli? He’d be ranked 9th in the list by BEREX mean. This is unsurprising; ranking by 50%ile ignores the standard deviations. A lower <em>BerexSD</em> value predicts more consistent BEREX scores, and the above does not reward players for that.</p><p>Ranking by 10th percentile can address this. The numbers can be read as ‘this player will match or exceed this BEREX score in 9 of 10 innings’. As always, the order is descending for batsmen and ascending for bowlers (so for bowlers, it’s technically the 90th percentile of scores).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h_zDXY60Ab3fMexeOBoRXg.png" /><figcaption>ODI Batsmen by BEREX 10%ile (2010–2022; Qual min 60 inns)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GsgcAMO4d3QZ9E_6OYw3sA.png" /><figcaption>ODI Bowlers by BEREX 10%ile (2010–2022; Qual min 60 wkts)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OD1ImitPW3Wdc8vug196qQ.png" /><figcaption>T20I Batsmen by BEREX 10%ile (2017–2022; Qual min 30 inns)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_8V7Kh5urnpYyTyfhR6vg.png" /><figcaption>T20I Bowlers by BEREX 10%ile (2017–2022; Qual min 30 wkts)</figcaption></figure><figure><img alt="Copyright AFP, Getty" src="https://cdn-images-1.medium.com/max/555/1*N4nTLzhU45Kql0U-Fdjn-g.png" /><figcaption>Top ranked players in each category by BEREX 10%ile</figcaption></figure><h3>Summary</h3><p>It is easy to apply BEREX to real-world cricket data. All we need is the Average and Strike Rate or Economy Rate. This simplicity is very powerful. It also makes it important to carefully select our datasets (based on time period, inning/wicket minimums, etc.). The choices we make impact the story told by our analysis. Indeed, this principle applies to most practical applications of data science.</p><p>This concludes our three-part series on BEREX. In <a href="https://medium.com/@cricketscience/average-vs-strike-rate-part-i-introducing-berex-aa35585d152e">Part I</a>, we introduced BEREX and derived its mathematics. In <a href="https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-ii-implementing-berex-26d45e10ffa2">Part II</a>, we implemented it in code and created contour plots to draw theoretical insights. Here in Part III, we applied BEREX to real-world player data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84a8da629d84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cricket Science — Average vs Strike Rate (Part II: Implementing BEREX)]]></title>
            <link>https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-ii-implementing-berex-26d45e10ffa2?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/26d45e10ffa2</guid>
            <category><![CDATA[mathematical-modeling]]></category>
            <category><![CDATA[cricket-analysis]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Fri, 15 Apr 2022 20:50:00 GMT</pubDate>
            <atom:updated>2022-05-14T23:12:01.183Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cricket Science — Average vs Strike Rate (Part II: Implementing BEREX)</h3><p>BEREX, short for BErnoulli Run EXpectation, is a mathematical model created to answer the question - <strong>how can average and strike rate be combined into a single metric in a statistically sound way? </strong><a href="https://medium.com/@cricketscience/average-vs-strike-rate-part-i-introducing-berex-aa35585d152e">Read Part I</a> to learn about the idea, what motivated it, and its mathematical derivation.</p><p>In Part II, we will implement the model in code and explore the model’s results.</p><h3>Code</h3><p>As derived in Part I, BEREX is the sum of these two expressions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*v1Ac2KdtsblWQ7GR" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/0*_IDuUA91EVNlZ4tF" /></figure><p>We can use for-loops for both sums. The parameters are easily calculated from the inputs (average and strike rate/economy rate) or independent, such as the number of overs <em>N</em>. The probability density function of the binomial distribution is included in SciPy (for Python) and the Statistics &amp; Machine Learning Toolbox (for MATLAB). Should you prefer to define that yourself, it is a simple combinatorics expression:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/0*aqX8PpThJehUdBbC" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa08c52ea6b1db1c8a6dbd5e8537f450/href">https://medium.com/media/aa08c52ea6b1db1c8a6dbd5e8537f450/href</a></iframe><h3>Contour Plots!</h3><p>I created the plots below six or seven years ago in MATLAB. I’ll save myself the effort of recreating them but the process is simple — call the BEREX function for each pair of Average and Strike Rate in a grid of choices. These plots also work for bowlers since the math is the same for both. For that case, the ‘Strike Rate’ on the y-axis should be interpreted to mean the runs conceded per 100 balls on average i.e. it is Economy Rate multiplied by <em>100/6</em>. Conventionally in cricket statistics, the term ‘Strike Rate’ has a different definition for bowlers (balls per dismissal).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*uTDaOhJ6_u30hQYazSieeQ.png" /><figcaption>BEREX means for 50-over innings</figcaption></figure><p>Pick an average on the x-axis and a strike rate on the y-axis. The BEREX mean is given by the color of their intersection point, as labeled in the colorbar legend. ‘Walking’ along any contour line corresponds to a constant BEREX mean. If comparing against actual cricket scores for context, note that this plot doesn’t include extras.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*HDaQ2z3E3Y-t8gP133s3bw.png" /><figcaption>BEREX means for 20-over innings</figcaption></figure><p>Notice how much flatter the contour lines are for T20s. This means that once batting average crosses around 30, any additional increase in average hardly affects the BEREX since the team is very unlikely to be all-out within 20 overs. The score is thus bounded by the scoring rate in those overs. A contrary effect is shown by the vertical lines in first plot for 50-over innings; for low averages, an increasing strike rate is not helpful because the team will likely be all out before 50 overs anyway. I encourage you to spend time with the plots and draw your own insights or questions.</p><h3>A Note on Standard Deviations</h3><p>Notice that the function returns two numbers. The first is the expected score we’ve discussed so far. The second is the <strong>standard deviation</strong> of these hypothetical simulated scores.</p><p><strong>Why is the standard deviation important?</strong> It is a measure of the relative certainty in the BEREX scores; a lower value suggests the imaginary team will more consistently score around the mean. Let’s use an example to clarify, using the calculated standard deviation as an error estimate (<em>N=50 overs</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/0*oVIR8qMNyFtbVgjX" /></figure><p>While the means are about the same, the scores from the player with the higher average will tend to cluster closer to 237 runs. The lower-average player’s BEREX scores are less consistent — there is a greater chance they will score substantially lesser (or greater) than 237. Is one better than the other? That depends on the strategy favored by a team and its existing composition.</p><p><strong>How is the standard deviation calculated?</strong> I’ve used a well-known formula for the <strong>variance</strong> of a random variable <em>X</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/203/0*40zO3nZ2IyxgaJHF" /></figure><p>Thus, the for-loops also calculate the expected values of the squares of the scores in the variables <em>Eoutsq</em> and <em>Eoversq</em>. The subtracted term is simply the square of the calculated mean. Standard Deviation is the square root of the variance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/0*WgHmwmHVw4uarMVJ" /></figure><p><strong>Will the standard deviation be useful in other ways?</strong> Yes! Thanks to the <strong>Central Limit Theorem</strong>, the scores resulting from BEREX are normally distributed. This fact can be applied to create a win probability calculator between two teams or hypothetical player-clone-teams. That’s a story for another day.</p><h3>More Contour Plots!</h3><p>Knowing the BEREX means and standard deviations, we can use <strong>z-scores</strong> to calculate the BEREX score at a chosen percentile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/0*4ENEIeujbUdIwXLm" /></figure><p>For example, the plots below are for 20 %ile, which means that BEREX expects the inning score to be greater 80% of the time. This is given by a z-score of about <em>-0.84</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*KNnDCAgFosVC7tDdQ7cREg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*reyFY-bX01vNXUMAAvuCZQ.png" /></figure><p>This is useful since it tells us what the BEREX score will be in at least 4 out of 5 matches. It incorporates a sense of reliability. Predictably, these plots favor Average as compared to the previous plots.</p><p>A very curious behavior also shows up here — at low averages and high strike rates, the contour lines are not vertical but lean towards the right! This implies that with a low average, increasing the strike rate beyond a point actually decreases the BEREX score at this percentile, albeit slightly. Why does this happen? Offer your thoughts in the comments. I’ll share my answer in a later post.</p><h3>Numerical vs Analytical Approaches</h3><p>We have used an analytical solution in our code. This means we derived the underlying mathematical expressions and use computation to calculate the exact values predicted by our model.</p><p>Contrast this with a numerical solution. This involves running several trials that approximate the true solution. For example, the BEREX model has an underlying ball-by-ball simulation rule: out with probability <em>p_out</em> and a constant amount of runs otherwise. We can simply generate a random number for each delivery and thereby simulate thousands of innings. The <strong>law of large numbers</strong> states that the mean of the resulting scores will converge towards the true (analytical) expected value.</p><p>Numerical solutions are very useful in cases where an analytical solution cannot be easily derived, or if it will be much more computationally expensive to compute the exact form of the mathematical expression. Indeed, we’ll put the approach to good use in future articles on Cricket Science.</p><h3>Summary and What’s Next</h3><p>The intuition of a sports fan is a powerful tool. The results generated by BEREX passed my intuitive sense for comparing <em>(Avg, SR)</em> pairs. It also works in a mathematically sound way by carefully defining a model and calculating its predictions. It therefore passes the criteria of my motivating question but with one caveat — the relevant outputs of the model are not a single metric. If you’re familiar with idea of <strong>degrees of freedom</strong> in statistics, you will know that was unlikely to happen. The BEREX mean and standard deviation can (and arguably should) be combined to get a better sense of assessment.</p><p>In <a href="https://medium.com/@cricketscience/average-vs-strike-rate-part-i-introducing-berex-aa35585d152e">Part I</a>, we were introduced to BEREX and derived its mathematics. Here, we implemented it in code and created contour plots to draw theoretical insights. In <a href="https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-iii-applying-berex-84a8da629d84">Part III</a>, let us apply BEREX to real-world player data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26d45e10ffa2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cricket Science — Average vs Strike Rate (Part I: Introducing BEREX)]]></title>
            <link>https://medium.com/@cricketscience/average-vs-strike-rate-part-i-introducing-berex-aa35585d152e?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa35585d152e</guid>
            <category><![CDATA[mathematical-modeling]]></category>
            <category><![CDATA[cricket]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[cricket-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Fri, 15 Apr 2022 06:20:31 GMT</pubDate>
            <atom:updated>2022-05-14T23:12:28.057Z</atom:updated>
            <content:encoded><![CDATA[<p>What is the hallmark of a good batsman? In simple numerical terms, it is the ability to score many runs and to do it fast. The same applies to bowlers, except it is their capacity to take wickets and limit run scoring that matters. This idea makes the <strong>Average</strong> and <strong>Strike Rate</strong> useful metrics:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/0*z8N2JoVqQxfcu0C4" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/136/0*Yd83RSwYZkWCJTKf" /></figure><p>Equivalently for bowlers, we have <strong>Average </strong>and <strong>Economy Rate</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/125/0*6o30daVKdo3fXouv" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/133/0*HjX_KynBn7NE5utp" /></figure><h3><strong>The Question</strong></h3><p>I was in sixth or seventh grade and speaking to a friend about batsmen averages and strike rates. We debated the relative importance of the two metrics. Of course, strike rate is not considered particularly relevant in test cricket, where teams have substantially more time to play. But for limited-overs cricket, increasing either of the two numbers indicates better batting. My friend proposed a method to combine the two:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/199/0*jiZJwKB5z3LOnZW1" /></figure><p>From which we can easily determine that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*VoNnNRI-6qox8wAP" /></figure><p>This seems reasonable on paper but I had my qualms.</p><ul><li>One, is an (Avg,SR) pair of (30,80) — with a product of 2400 — equally valuable as (40,60) or (20,120)? Perhaps in 50 over cricket but certainly not in the then-newfangled Twenty20 format.</li><li>Two, the mathematical expression is rather arbitrary. This is because the very choice of multiplication is arbitrary. Why should the exponent for the Runs term equal to 2 instead of, say, 1.8 or 2.5?</li><li>Three, the resulting units and scale do not have a natural interpretation for a cricket enthusiast (I was admittedly bordering on nitpicky by now).</li></ul><p>I was thus left with the question — <strong>how can average and strike rate be combined into a single metric in a statistically sound way?</strong></p><p>This can similarly be posed for bowlers. For the sake of simplicity, I will discuss the batting metrics in this article and later generalize our results to bowling metrics as well.</p><h3>The Idea</h3><p>I didn’t have an ‘aha’ moment when I came up with a satisfying answer; it was a gradual process of noodling with ideas during my undergrad. With the advantage of hindsight, we’ll take a much more direct path.</p><p>Consider a player with an average of 30 and a strike rate of 75. Their ‘average inning’ will be 30 off 40 balls (since 75 = 100 * 30/40). We can imagine a simple ball-by-ball simulation of an inning: for each ball faced, they have a 1 in 40 chance of being out. Otherwise, they score 0.75 runs. Keep repeating this until they get out. This is an example of a <strong>Bernoulli process</strong> in statistics and probability.</p><p>Now imagine a team consisting of eleven copies of that exact player. We can use the above idea to simulate a full inning of this hypothetical team. Stop simulating when 10 wickets have fallen or all overs are bowled. These team scores could be a quality measure that addresses my qualms noted above. It’s measuring the ability to contribute to the team score — which directly affects the primary goal of winning games. The relative importance of the two metrics automatically ‘adapts’ when we change the number of overs in the inning. We won’t use a conjured-up ‘seems reasonable’ equation. The resulting units are runs and its values comparable to inning scores that cricket fans can intuitively judge. Three for three!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O3oYw1M0X5WbKEUric9omA.jpeg" /><figcaption>A good idea is <em>almost as satisfying as the sweet sound of leather on willow</em></figcaption></figure><h3>Constructing the Mathematical Model</h3><p>Let’s begin by formalizing the idea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/0*iKlfP3XE06cHL6VV" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/228/0*kaD665fI3PH8S6Oq" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/0*tF00X933YMyjpgrv" /></figure><p>For a single ball, this gives</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/0*nNFgFbTtbMMYpxbJ" /></figure><p>If the player isn’t out on a given ball, we assumed they score a constant number of runs instead. However, this isn’t exactly one-hundredth of their strike rate. The ‘average inning’ is <em>Avg</em> runs scored off <em>bpd</em> balls. The latter includes the one ball on which they were dismissed, so for the actual scoring balls we define:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/430/0*rdkmxeyPe9abCLcX" /></figure><p>We now have the parameters of each <strong>Bernoulli trial</strong> — the process will be a finite sequence of such independent trials. The <strong>expected value</strong> of the runs scored by the hypothetical team-of-clones is, by definition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/134/0*6f8oXD7Z4eqBiICp" /><figcaption>We multiply every possible score x with its corresponding probability, then sum all such terms</figcaption></figure><p>I call this value <strong>BEREX</strong>, an acronym for <strong>BE</strong>rnoulli <strong>R</strong>un <strong>EX</strong>pectation. Split the calculation for two cases: Case 1 is if the hypothetical team-of-clones is all out; Case 2 is if 9 or fewer wickets fall but the scheduled overs are all bowled. In Case 1, for the example of a 50-over inning, the team will face anywhere from 10 to 300 balls of which exactly 10 were outs. If they faced exactly <em>b</em> balls:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/0*vmp7xK77YyTfyu3_" /></figure><p>This would happen if there were 9 outs in <em>b-1</em> balls and the tenth out on the last ball. The probability of this is calculated using the probability mass function of the <strong>Binomial distribution</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/0*r22zcuybvcTCu2O1" /></figure><p>Generalizing to a maximum inning length of N balls (<em>N=300</em> for ODIs, <em>N=120</em> for T20s and so on):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/0*v9dAv4t7IZjGvf-Q" /></figure><p>Now for case 2, the number of balls is set to <em>N</em>, of which anywhere from 0 to 9 balls were outs. Here, the summation will be over the number of wickets <em>w</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/0*-3dE6AlPLz_1R6Zq" /></figure><p>Finally,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/0*vKIZOEhOZ2m0d7tr" /></figure><p>Some of you may be questioning a couple of key features. Is the probability of dismissal really constant throughout? No. Does a player score a constant, say, 0.83 runs on every other ball? Obviously not. These are called <strong>simplifying assumptions</strong>, and they are an essential part of practically any mathematical model. One of my favorite quotes is about this:</p><blockquote>“All models are wrong, but some are useful.”</blockquote><blockquote>-George E.P. Box</blockquote><p>In future articles, I hope to share my work on the dynamics of dismissal probability and on estimating the likelihood of specific outcomes for a ball-by-ball simulator. For now, let’s test BEREX!</p><h3>Example Results</h3><p>We can apply the model to any pair of average and scoring (or conceding) rate, whether for a player’s career, a season/tournament’s performance, or something hypothetical.</p><p>How does BEREX judge the trio of <em>(Avg, SR)</em> pairs I’d considered in middle school? For a 50-over game, <em>(30, 80)</em> wins with a BEREX of 227.6 runs. In other words, a team consisting of players who all average 30 with a strike rate of 80 will score an average of 227.6 runs per inning, excluding extras. Next is <em>(20, 120)</em> with 199.5 runs and <em>(40, 60)</em> comes last at 179.6 runs. The high batting average doesn’t help all that much when the scoring rate is a measly 3.6 runs per over.</p><p>For a Twenty20 game however, the order goes <em>(20, 120)</em>: 139.7 runs &gt; <em>(30, 80)</em>: 96.0 runs &gt; <em>(40, 60)</em>: 72.0 runs. Here, the chances of an all-out inning are much lower, so the strike rate becomes even more important.</p><p>Let’s now consider some career figures in 50-over ODIs. Virat Kohli <em>(58.07, 92.92)</em> as of this writing gets 277.9 runs; Virender Sehwag <em>(25.05, 104.33)</em> gets 287.5 runs; Shahid Afridi <em>(23.57, 117.0)</em> is at 232.6 runs. For bowlers, BEREX uses <em>(Avg, Econ)</em> and is interpreted as the runs <em>conceded</em> so a smaller value is better. Muralidaran <em>(23.89, 3.93)</em> is at 185.1 runs; Glenn McGrath <em>(22.02, 3.88)</em> at 179.0 runs; Zaheer Khan <em>(29.43, 4.93)</em> at 231.0 runs.</p><h3>Summary and What’s Next</h3><p><strong>BEREX</strong>, short for Bernoulli Run Expectation, is the expected runs scored (or conceded) by a hypothetical team of eleven clones of a player facing an ‘average’ bowling (or batting) attack. It is a statistically sound model for assigning a run value to a pair of Batting Average and Strike Rate, or Bowling Average and Economy Rate. Since the typical values of these metrics have evolved over time, BEREX too shouldn’t be used for comparison across eras. I find it most interesting for answering questions of hypothetical comparisons or for comparing season/tournament performances.</p><p><a href="https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-ii-implementing-berex-26d45e10ffa2">Read Part II</a> to see BEREX implemented in code and view some pretty visualizations of its predictions. In <a href="https://medium.com/@cricketscience/cricket-science-average-vs-strike-rate-part-iii-applying-berex-84a8da629d84">Part III</a>, I will apply the model to real-world player data. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa35585d152e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Cricket Science?]]></title>
            <link>https://medium.com/@cricketscience/why-cricket-science-127f6f4b0145?source=rss-a2eb3180dcc6------2</link>
            <guid isPermaLink="false">https://medium.com/p/127f6f4b0145</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[nostalgia]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cricket]]></category>
            <dc:creator><![CDATA[Div Tiwari]]></dc:creator>
            <pubDate>Mon, 28 Mar 2022 04:23:43 GMT</pubDate>
            <atom:updated>2022-03-28T04:24:44.049Z</atom:updated>
            <content:encoded><![CDATA[<p>The year is 2001. The place is Ranchi, a small town in India. A short, bespectacled, eight year old boy is playing cards with his friend. But these aren’t ordinary playing cards. They each have a picture of a sportsman and at least a dozen numbers on them. The boy isn’t doing so well —his opponent seems to better know the ‘right’ numbers to call out from the cards.</p><p>Those were cricket slam cards. The boy was me. I didn’t know it then, but I would end up spending a lot of my free time on numbers and cricket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QoWlapptB5uUuKJoswAjug.jpeg" /><figcaption>Examples of cricket slam cards, ca. 2010 (Image from u/revermind_ on reddit.com)</figcaption></figure><p>India has a strong affinity for the sport of cricket. Cricket has a strong affinity for numbers and statistics. As a math-obsessed Indian, it wasn’t long before I had a light-bulb moment of diving deeper into this interest.</p><p>Like any sport, cricket generates a lot of numbers. The outcome of each delivery, the runs scored by a batsman, the winning margin in a match, the winning percentage of a team, and so on. I have applied statistics and probability to such data, created mathematical models of the game, utilized machine learning to gain novel insights, analyzed spectrograms of time series, coded a library of functions and simulators, and more. This has been ongoing for about fifteen years, on and off. It has been mostly ‘off’ for the last couple of years though, and that has motivated me to finally begin sharing my work. I hope that someone is able to pick up from where I’ve left off. A deeper part of me hopes that the process will spur me to resume this labor of love.</p><p>Through these upcoming stories, we will learn about applying principles of data science, noodling with scientific hypotheses, numerical programming, and of course — about the beautiful patterns concealed within cricket. If you are new to the game, I suggest watching <a href="https://www.youtube.com/watch?v=g-beFHld19c">this 3-minute video</a> or, if you are one of the rare breed of internet users with more time to spare, <a href="https://www.youtube.com/watch?v=NZGLHdcw2RM">this 17-minute episode</a> of Explained.</p><p>How will this be different from any other cricket analysis blog? My choice of the word “science” is very deliberate. We will not merely be calculating averages and standard deviations. Instead, we will utilize the scientific method: formulate hypotheses, analyze data, create mathematically sound theories, and then use those theories to make testable predictions. What emerges is a fascinating series of results and ideas. It will be my goal to make you as excited about it as it is to me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=127f6f4b0145" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>