R

Fast Arbitrage Detection Using Linear Programming

Linear programming has been used many times before to detect arbitrage in FX trading. However, to use in live trading these solutions require solving a linear program after each price update. So I ask a different question: for each pair, what is the minimum exchange rate such that an arbitrage exists? This way, if the exchange rate updates for a pair, all we have to do is compare the new exchange rate to the minimum exchange rate for an arbitrage to exist.

Survey Nonresponse: Partial Identification in Stan

Let’s say you send out a survey to 100 random people with a single yes/no question. 80 people response and 60 of those 80 people say yes and the other 20 say no. The classic question in statistics is: what percent of the population would say yes to this question if they all responded? The first approach would be to say 60 of the 80 responded said yes so we would estimate that the population “yes rate” would be 75%.

Flattening the Curve

With the recent spread of COVID-19, I decided to take a look at infectious disease models and how these models generate the “Flattening the Curve” plot. Source: https://www.wired.com/story/whats-social-distancing-flattening-curve-covid-19-questions/ The simplest model of infectious disease spread is the SIR model. In this model, there are three groups: Susceptible (\(S\)), Infected (\(I\)), and Recovered (\(R\)). The susceptible spread the disease to the infected and the infected eventually recover. The model is governed by three differential equations:

2018 Putnam Problem A2 Exploration in R

Problem A2 of the 2018 Putnam Competition states: Let \(S_1, S_2, \dots, S_{2^n-1}\) be the nonempty subsets of \(\{1,2,\dots,n\}\) in some order, and let \(M\) be the \((2^n-1) \times (2^n-1)\) matrix whose \((i,j)\) entry is \[ m_{ij} = \begin{cases} 0 & \mbox{if }S_i \cap S_j = \emptyset; \\ 1 & \mbox{otherwise.} \end{cases} \] Calculate the determinant of \(M\). First thing to note is that we can generate all nonempty subsets of \(\{1, 2, \ldots, n\}\) by converting each integer from \(1\) to \(2^{n} - 1\) to binary.