Which bowlers threaten your stumps the most? Given a table of all wickets taken during some particular set of matches and two thresholds, w and p, return a table of the bowlers who have taken at least w wickets with a proportional of at least p of those wickets being either bowled or LBW. The table returned should be sorted in descending order of this proportion. If bowlers share the same proportion, they should be ordered in descending order of total wickets.
The input table will have two variables, Bowler and Dismissal. Both are string vectors. The first is the names of the bowlers, the second is the type of wicket, which will be from the set: "bowled", "caught", "caught and bowled", "hit wicket", "lbw", "stumped".
The output table should have three variables: Bowler, Wickets, and WWProp. The first is the names of the bowlers (string), the second is the number of wickets taken by each bowler (double), and the third is the proportion of each bowler's wickets that were bowled or LBW.
For example, with thresholds of w = 2, p = 0.5:
b = ["Ben";"Matt";"Renee";"Renee";"Ben";"Ned";"Ben";"Ned"];
w = ["hit wicket";"lbw";"bowled";"lbw";"lbw";"stumped";"bowled";"caught and bowled"];
wickets = table(b,w,'VariableNames',["Bowler","Dismissal"])
wickets =
8×2 table
Bowler Dismissal
_______ ___________________
"Ben" "hit wicket"
"Matt" "lbw"
"Renee" "bowled"
"Renee" "lbw"
"Ben" "lbw"
"Ned" "stumped"
"Ben" "bowled"
"Ned" "caught and bowled"
wwprop = wicketwicketprop(wickets,2,0.5)
wwprop =
2×3 table
Bowler Wickets WWProp
_______ _______ _______
"Renee" 2 1
"Ben" 3 0.66667
Solution Stats
Problem Comments
3 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers15
Suggested Problems
-
993 Solvers
-
Remove the two elements next to NaN value
702 Solvers
-
275 Solvers
-
Converts numbers into characters
1959 Solvers
-
1639 Solvers
More from this Author33
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
The example is wrong, but the problem description is correct. We must not count the caught-and-bowled events, and probability can also be equal to the threshold despite the example.
Overall these problems are not hard, but they require close attention. And I recommend using tables; these problems are perfect for a DBMS lecture.
@Raphael: Thank you for catching that - I was tweaking the example and didn't update the image correctly. I have now.
To clarify: Raphael is correct that "caught and bowled" does *not* count to the "bowled" category. And yes, in the example, if Ned's second wicket was "bowled" or "lbw" instead of "caught and bowled", then he would have WWProp = 0.5 and should be included as the last row of the output table, having at least 2 wickets and a proportion of at least 0.5.