I was playing Monster Hunter, and was trying to get a particular item for killing a monster – specifically a number of Rathian Spikes. There are 5 chances to get the item per kill – three of which have a drop chance of 5% and the other two with a 7% drop chance. I was wondering what the actual probability per kill would be, so I decided to make a small program in F# using Linqpad to calculate the probability.
By building the formula into a product, I was able to use a reduce function on my list to do the calculation. Here is the final program: https://gist.github.com/dotsonjb14/efa9ddaa26eeba89d405
After the fold, I used an in statement to turn the function into a single statement. The first dump is the sanity check, which should come out to 75% every time. The second dump is the actual calculation I wanted to make. In this case, the result is ~25.85%, which lets me know that I need to kill roughly four monsters to get one spike. This allows me to estimate how long it will take me to get all the spikes that I need.