Expectorant
beginner mode
Exact Change: Repayment with Cash
All payment types
p=0% n=0
instructions
Expectorant is a stochastic, nerdtastic restaurant bill splitting app and random number spinner. Just enter a probability between 0 and 1 or an expression that evaluates to a probability (more on that below) and press Expectorize.
Basic use cases
Say you owe me $7 for lunch but only have a twenty.
If you give me the twenty with probability 7/20 (35%) then in expectation you've paid me $7!
So type in 7/20
and spin the spinner.
If it comes up green then I lucked out and get the $20.
Or of course there's what the Soule-Reeveses call pumpkin-patching or skyootling where instead of paying someone the $X you owe them, you pay them 10X but with only 1/10 probability, and nothing otherwise. That's handy for reducing transactional overhead: 90% of the time you don't have to make any money change hands or ledger anything. It especially saves time if the amount owed hasn't actually been computed yet. As long as you can unambiguously compute it if/when the 10% expectorization happens, nine times out of ten you don't have to bother.
Exact (expected) change
— @
syntax
Suppose you owe me an especially awkward amount like $8.27 and you have a five and a twenty.
Paying me $5 is kind of close so if you probably give the five and maybe give me the twenty then that could be fair.
Can we make it exactly fair?
Yes we can!
Enter the amount you owe, an @-sign, followed by two amounts
— the first lower than you owe and the second greater.
Expectorant turns that “probably” and “maybe” into exact probabilities.
In this example you'd type
8.27@5,20
which gets turned into
$$\frac{8.27-5}{20-5} \approx 22\%$$
which is the probability \(p\) such that
\((1-p)\cdot 5 + p\cdot 20 = 8.27\).
That's the exquisitely fair probability \(p\) vs \(1-p\) that you should give me the twenty vs the five so that you're giving me exactly $8.27 in expectation!
Stochastic, nerdtastic restaurant bill splitting
— :
syntax
Say the subtotal for your restaurant bill is $100 and the items on the bill are $5, $25, $60, and $10.
Enter 100:5
and have the person who ordered the $5 item spin the spinner.
If it comes up green (a 5% chance) they get to pay the whole bill!
If not, amend the expression as 100:5,25
and repeat for the person who got the $25 item.
They'll “win” with probability \(\frac{25}{100-5}\).
If they're off the hook, amend again to 100:5,25,60
.
This time most likely,
\(p = \frac{60}{100-5-25} \approx 86\%\),
the $60 person will win the honor of paying the bill.
If not, notice that
100:5,25,60,10
yields
\(\frac{10}{100-5-25-60} = 1\).
So if the process makes it to the last item on the bill then whoever got that item is it.
Mathemagically, it doesn't matter what order you put the items in — each person “wins” (pays the whole bill) with probability equal to their own fair share of the bill. In other words, you pay in expectation exactly your fair share. Including tax and tip, even though we never entered those. Pretty slick!
Speaking of tips, you can minimize the hassle by starting with the most expensive items. Then you don't have to figure out who most of the items belong to.
What if three people split the $16
nondescript nachos with broken javascript?
Just treat it as 3 items, costing $16/3 each.
And you can literally type the prices as 16/3
since
Expectorant speaks arithmetic.
Credits
Built by Christopher Moravec, Bethany Soule, and Daniel Reeves. Based on an Android app that Soule and Reeves published in 2010 (!) and that's technically still in Google's app store but doesn't work on modern phones. Thanks to Dave Pennock who invented the restaurant bill-splitting algorithm. UI enhancements by Daniel Zwell. See the original blog post for more.