## Treat Coin

### The System

I'm taking Cryptography in this term and they also brought up Bitcoin. The mathematically most beautiful things can get ugly and I will never invest into cryptocurrency. I got creative though and coded a little script for managing my money spending habits.

I called this idea "Treat Coin", because it is a currency for your (unnecessary) material desires. It is not related to cryptocurrency and works completely offline. Basically, it generates a random number between 1 and 24. If it is 11 then this is the jackpot and you will gain 4 coins. The numbers between 9 and 16 win something. Let $X$ be the random variable representing the win and $w(i)$ the win if $i$ was drawn. Its expected value is

$\mathbb E(X) = \sum_{i=1}^{24} \frac 1{24} w(i) = \frac 1{24}\cdot 4 + \frac 2{24}\cdot 2 + \frac 4{24}\cdot 1 + \frac 2{24}\cdot \frac 12 + \frac 2{24}\cdot \frac 14 = 0.5625.$In a month this amounts to $16.875$ coins. The next task is to decide how much a coin is worth in your currency. For me it is $2.5$. You can find the Lua scripts here and here (copy them in a folder and name them $\texttt{main.lua}$ and $\texttt{config.lua}$). They only work on Linux, but if you want to use the system, all you actually need is a die, pen and paper. 😉