Posts

Showing posts from April, 2016

Beat the Streak: Day Four

In this blog post, I will introduce an idea I recently came up with to predict the most likely players to get a hit in a given game based on situational factors such as opposing starter, opposing team, ballpark, and so on. I have not written much in this blog on this topic, although I did some work on this topic last fall which you can find here . In that work, I had the chance to explore a bunch of ideas that I had, but ultimately had to back up a few steps and rethink my approach. I think the ideas are still valid, and will continue refine them as time permits. A few weeks ago, I came up with a new approach that is completely different from my other approaches so far, and I will share it in the rest of this post. Defining the Problem Before we dive into the math, let's talk about what exactly we are trying to do. The end goal is to pick the player who is most likely to get a hit on a given day based on factors associated to the games for that day. Some of these facto

Counting Coprime Pairs Using Inclusion Exclusion

The principle of inclusion exclusion is a very powerful idea that can be used to solve alot of problems that arise in combinatorics. In this blog post, I will show how it can be used to solve one problem in particular, and I will also provide a very elegant recursive implementation of it. Let's say we want to count the number of positive integers \( k \) that are less than or equal to \( m \) and relatively prime to \( n \). Using set theoretic notation, week seek to find the cardinality of the set \( \{ p \mid p \in \{ 1, 2, \dots, m \}, \gcd(n,p) == 1 \} \) where \( gcd \) is the greatest common divisor function. Let's denote the function that counts the cardinality of this set as \( f(n,m) \). Now that the problem has been defined, I will show how to solve it using brute force methods. We can map the mathematical definition of the problem to a haskell program very naturally using a list comprehension. f :: Int -> Int -> Int f n m = length [p | p &lt- [