Magician-turned-mathematician uncovers bias in coin flipping (2004)
news.stanford.edu
news.stanford.edu
The Von Neuman method is a great way at demonstrating that removal of bias is possible, but not necessarily practical (especially at high bandwidth). In practice, you want to just cryptographic_hash(coin flips), which should maximize your entropy up to the entropy limit of 1/2 the hashsize (assuming you have a perfect cryptographic hash function).
A 512-bit perfect cryptographic hash can only support 256-bits of entropy, due to the birthday attack.
The problem is that perfectly-random codes can't be decoded very easily... so this little factoid is kind of worthless in most cases. Fortunately, we don't actually care what the information looks like when flipping coins. We usually just want "some random message", so no need to decode in this application!
------
Cryptographers assume hash-functions are perfect random codes (they aren't in theory, but they are in practice... at least until they're cracked. Kinda funny how that works out). As such, the cryptohash(message) methodology should also reach the Shannon-limit, as long as your cryptohash remains secure... and you stay within the blocksize restrictions of the hash.
Except there is no such thing (not in the sense you need it) - it too would be a perfect source of randomness, and you're just pushing the problem down the road.
As an example, NIST publication 800-90B recommends multiple randomness extractors, one of which is SHA. They recommend using twice the amount of entropy in as the entropy out to get random "enough" bits. Thus even SHA is not going to mix bits well enough as you want.
(The things called perfect hash functions in the literature map N items into N slots with no collisions, which is not what is needed here).
As a perhaps surprising counterexample to any simple solution, here [1] is a math paper with a proof that there can be no optimal algorithm that is best for all values of coin bias.
Here's [2] a cool walkthough on some of the ideas in theory that have been investigated.
[1] https://web.eecs.umich.edu/~qstout/abs/AnnProb84.html [2] http://www.eecs.harvard.edu/~michaelm/coinflipext.pdf
???
Okay, lets choose the simplest hash function of them all: a 1-bit XOR (resulting in a 1-bit "hash").
Lets say I flip the 75% biased coin 100 times, count heads as 1 and tails as 0. I XOR all the results together. What's the probability of XOR(all) == 1, and what's the probability that XOR(all) == 0?
You'll find that its quite close to 50/50, which is the limit to the amount of entropy you can pull from a 1-bit hash function.
---------
Now lets see for smaller values:
1 flip: 75% chance of 1, 25% of 0. Which is the limit of information so far.
2 flips: ... you know what? Imma write a program and get back to ya a bit later. I probably will edit my post.
------
2 flips: 62% chance of Parity0 3 flips: 43% chance of Parity0 4 flips: 53% chance of Parity0
Etc. etc. etc.
By 16 flips, its 49.9985% chance of Parity0, pretty close to unbiased. It gets pretty hard to distinguish this coin from an unbiased one.
--------
I'm not sure if you need a cryptographic hash actually. Its just that cryptographic hashes are close enough to random that its easier to use.
Now I'm curious if a CRC32 would efficiently extract 16-bits of entropy from biased coins. CRC32 is clearly not a cryptographic hash, but its pretty good as an "avalanche" due to the nature of GF-arithmetic.
All you're doing is trying to reinvent the Law of Large Numbers - nothing in this post shows a perfect hash function, and in fact is demonstrating my point - by you putting biased data into a hash you're getting biased data out.
To completely remove the bias you need infinite flips. And thus you have improved nothing.
Next, if you're going to flip 100 times to get 1 bit out, simply use the Neumann method - it does work, uses only a few flips on average.
Here's a proof why your method doesn't work: Let p = prob of getting a 1, q = 1-p is prob of getting a 0. Then XORing n of these together is a 1 iff there are an odd number of 1 bits. This happens Sum_{j=1 to N by odd} nCj p^j (1-q)^(n-j) of the time. This simplifies to (1-(1-2p)^n)/2. For this to be exactly 1/2, which is no bias, p must be exactly 1/2. There is no other value that doesn't fail.
This argument can be extended to whatever hash functions you want. You're not going to get the outcome you desire no matter how you structure it.
>I'm not sure if you need a cryptographic hash actually.
It matters not the hash. None will do what you want.
This is why when crpyto uses weak PRNGs at the front, even after all the powerful crypto in the middle, they are weakened. You're trying to do what decades of cryptographers know is impossible.
The post is very confusing, in no case can deterministic hashing increase the entropy. And if it outputs only half of input entropy then it's only 8% more efficient than von neumann in this case.
But the measured bias here is a 51% chance of getting what you started with. Which means that if you flip over and over again, there is a correlation between consecutive entries.
HTHHTHHTTHHH
HHHTTTHHTTHT
Should be fair. Though there is order now when the coin was unfair.
Only over time: this doesn’t help if you need _one_ fair flip.
Not random: for any 2 flips in sequence, you want a probability of ¼ to get two heads. This gets you either 70% × 30% or 30% × 70%, both of which are 0.21. That’s only 84% of the expected 0.25. In general, longer sequences of heads or tails are too rare with this method (e.g. for four flips: 70% × 30% × 70% × 30% is 0.0441; only 70.56% of the expected 0.0625. The probability of 6 consecutive heads or tails is less than 60% of what it should be, etc.)
It’s not 100% the same, but understanding it should enable you to use the same idea for this problem.
Based on this algorithm, I've been building a bot [2] to integrate with Betfair's games API to play automatically for me.
After finishing the first iteration, running it for a bit and losing a few Euros, I quickly realised that some of my assumptions as laid out in the README were wrong (I will be updating this soon). Namely, I wasn't accounting for Betfair's commission on winnings (silly me). I currently have an EU-based account, which has a 6.5 per cent commission on winnings. UK-based accounts have the minimum at 5 per cent. The commission has an effect on the cheapest profitable odds you can provide, which has an effect on whether people want to match bets at those odds.
With this in mind, it quickly becomes clear that any unmatched bets you see in the market are far from the maximum profitable odds. This makes sense, and competing based on odds becomes impossible at this point. I am led to believe that the only way to make money is by having a UK-based account plus getting the bets to the market first. I have a few ideas on how to do this.
If I can get the bets to match at odds that guarantee profit in the long-run assuming UK-based commission of 5 per cent, then I'm going to call it a day.
Regardless, I'm not expecting to make too much money from this. I have a lot of free time right now (looking for a job), so if anyone wants to get into anything else available on Betfair together, then please get in touch at the email on my Github through [2]. My discrete probability and programming are okay, but it would be great to have someone who could share their statistics knowledge.
I used to work on those products, way back in 2008 or so. Let me save you some time: you won't get any action at good odds. Or, if you do, it'll be a tiny amount.
Betfair run their own bots on those markets AND they get their bets into the market BEFORE the market opens to the public. Good luck anyway!
Some time ago I had a similar project with BetFair soccer matches. I assumed that the number of goals from each team is given by a Poisson process. Then, I used the largest market (Win/Lose/Draw) to estimate this parameter. With this information I could estimate the "fair" odds of more exotics bets (like e.g. team A will score 3 goals more than team B), which were often mispriced, and then use the Kelly criterion to estimate how much to bet.
All in all a nice project, but... at the very end -just before deploying the bot- I realised that the BetFair Exchange is not open to Germans, so I wrote a blog post and open sourced the code. Still, a nice learning opportunity :-)
Did you backtest and show potential returns? Can you link to your model? Did you come across "Scoring dynamics across professional team sports: tempo, balance and predictability" [1]? They apply a Poisson model to team sports. I mentioned this paper to a company involved in betting who I interviewed with once, and they told me that they were doing something similar, but way more involved. It demotivated me somewhat regarding implementing it, making me wonder whether there really was any juice left to be squeezed from it.
> Across all sports, scoring tempo - when scoring events occur - is remarkably well-described by a Poisson process, in which scoring events occur independently with a sport-specific rate at each second on the game clock.
So, yes, basically that was my concept. Estimate its parameters and then you'll have the "real" odds. Any difference with the market ones is a potential of profit (considering the house fees).
I couldn't backtest it since I couldn't find free historical data for all types of markets (then again, maybe I didn't look hard enough). I forward tested it, though, and it seemed to work.
My code is here [1], which also links to a blog post describing the method. Feel free to take a look and contact me to discuss these ideas.
Also, if you're interested in mathematically modelling probabilities, we are looking for team members to develop a product to estimate the risk of default in loans. After all, a loan is another kind of bet, that takes place in a slightly harder to model environment.
Walsh and Ranogajec took on the might of global gaming markets and managed to consistently win over three decades. Much like the most advanced hedge funds, which employ armies of PhDs to identify patterns in financial markets, Walsh and Ranogajec’s consortium, called the Bank Roll, created statistical models that allowed them to exploit mispricings in betting odds wherever they could be found
https://www.afr.com/opinion/david-walsh-s-wisdom-beats-the-o...
But by this reasoning no one would play blackjack at the casino. That is, how do you know people laying these bets aren't just gambling at a disadvantage? You could view the whole thing as one more novelty game the casino is spreading.
I am assuming that there will be punters who bite at the odds I provide. If there weren't, then the game would not be sustainable.
I came across a "betting guide" for sale for this game which claims to advise on bets based on the "trends" seen in the game. I don't know what this means, but it gives me hope that there are people out there willing to part with their money in my direction.
Failing that, the novelty was an interesting one, and it's all about the journey, dude!
I'm just proposing another possibility is that everyone playing on both sides is a "punter" having fun (or deceiving themselves). In any case, that everyone is losing long-term. With 5% vig I'd guess that's the most likely possibility.
45% of players don’t play well enough to win, even at even odds. Kind of mini-Dunning Krueger. They’re hoping for luck, and love to tell stories to their friends when they win.
30% are degenerate gamblers.
The balance play well enough that the loss rate is sufficiently slow so as to pay for the entertainment value.
There are still many many many people who are willing to bet on the results of the US presidential election: https://www.thedailybeast.com/gamblers-bet-big-on-trump-and-...
Of course, if those prices are accurate, then they will lose money in the long-run after fees. For players who are betting more frequently and over a longer term, it's like any other speculation: You might assess the $0.30 underdog to have a 40% chance of winning. She is still the underdog, but you profit over the long run by buying her at her too-low price. Those players are scooping that value wherever they can find it.
For major electoral events that involve a populist with a large, loyal, and misinformed fanbase, the value pretty much finds you. Both of the described groups are making lots of money because the markets are wildly mispriced.
We were betting on the results of an event that already happened. No Twitter analysis necessary.
It's basically free money.
That’s how I was taught to do it as a kid when we were playing for fun. I never really thought about the reasoning until now.
If you talk to people deep into the performance magic community, there are myths and legends of people who practice dice rolling to the point where they can influence the outcome of a dice roll. I suppose training for hours a day for years on end could have some such influence.
Mind you, none of these moves will fly in a modern casino.
As I recall, the techniques generally involve not making normal "fair" free-tumbling rolls, but constraining the die movements somehow. Things like tossing them into a corner or making one of the pair spin flat, around only a vertical axis.
It's not terribly hard to influence the outcome of a die roll. You can roll it end over end like a wheel so two of the faces remain on the sides and can't be the result.
"18. Heads-or-tails. This I take on the good and sufficient word of Eddie Joseph. He explains how it is possible to flip a borrowed coin, and call heads or tails correctly every time.
"No trick to it -- just mechanical uniformity of action. It is obvious (when pointed out) that which face of the coin comes up depends simply on the number of revolutions the coin makes; and this depends on the weight of the coin, the height of the flip, and the force of the spin.
"By always using one denomination of coin, you fix the weight. The uniform flip of your right thumb comes with practice. To get a uniform height, pick some marked point on the wall, and practice until you can toss the coin just that high every time.
"You must also catch the coin on your left palm at exactly the same height each time -- your waist, naturally, is the easiest.
"Once you attain true uniformity, you will discover that the coin always comes down showing the same face that went up, or else always the opposite face. Experiment with different heights of toss, keeping track of the way the coin comes down. Never vary the force of your thumb flip because that is the hardest to judge.
"In performance, pick a mark such as a molding or picture frame on the wall of the room where you happen to be, make one trial toss to that height, and see whether the coin comes down the same as it went up, or opposite. Every time you toss to this mark afterward, the result should be identical.
> Diaconis himself has trained his thumb to flip a coin and make it come up heads 10 out of 10 times
If his actual success rate is, say, 70 out 100 10/10 is easy enough to get by chance.
990 out of 1000 would be much more pressive.
There were popular coins made specifically for Pokémon TCG then, and they happened to be large and thick and plastic and heavy, so the cheating was widespread.
I was one of the many kids who did this routinely. But there was one kid who took first place nearly every week, out of a field of 50+ entrants. “He must cheat the coin, AND be an amazing deck builder and card player on top of that”, I thought.
Then one week I was matched against him, winner goes to top 8.
Our decks were nearly identical, I could flip heads every time, I was a strong player. “50-50” I thought.
Turn one. Retreat Scyther, in Electabuzz, Thundershock. I flip my giant coin, and before it flattens, he picks it up and hands it back to me. “Flip it higher please.”
He must know I’m cheating. I assumed he must be cheating too though, every other kid is, and he wins this tournament every week!
Guilty, I flipped the coin fair this time, higher. Before it flattens he picks it up again, hands it back to me. “Higher please.”
I lost every coin flip that match. He won, went to the top 8, later won the tournament for the nth week in a row.
It wasn’t until adulthood that I realized how he was winning every tournament. In a field full of cheaters trying to flip heads every time, all he had to do was wait for the coin to enter that terminal spinning motion every coin does right before it flattens. Well practiced at this, if he sees that it’s about to flatten heads, he quickly grabs it and hands it back to you. “Higher please.” Repeat until the coin flattens tails.
His tactic was a silver bullet in a field full of flip cheaters. Nobody ever questioned his intentions when he grabbed the coin and asked for a higher flip.
For comparison, the other method (where the coin rotates about its vertical axis) is something you can learn to do tolerably well in a few minutes, and to do very well after a month or two at most. The motion of the coin will look perfect, and you can even get the "ding!" noise of a real flip. The only giveaway is the hand position; a real flip is done with the thumb under the coin, and this trick (for me, anyway) requires the thumb to be on top.
Source: taught myself to do this many years ago. I'm not a magician and have never used it to win money, I just use this to settle arguments between my kids.
If you have a very practiced, consistent flip, you can always get the same result.
Good for him. He made the right choice I think.
I'm a vi person by muscle-memory, and the stability there means I've learned a thing or two about it. But I've used emacs enough that I'm comfortable there, too, at least to a point.
Don't get me wrong, I love playing with new toys. But I also love not having to think about my tools - I'd rather think about what I'm building.
If you flip a coin through the air so that it rapidly rotates (say more than 15-20 times) before being caught, that seems like it would erase the bias.
If there isn't decent spin, then "all bets are off" (quite literally).
As a matter of procedure, there should be a rule: the coin tosser must place the coin onto index finger, which is coiled around the thumb, such that just the edge of the coin is struck from below by the thumbnail, when the thumb is flicked, sending the coin upward in rapid rotation. There should be additional rules that the coin should attain a height of at least one head height above the top of the tosser's head, or something of the sort.
Group Representations In Probability And Statistics
Magical Mathematics: The Mathematical Ideas That Animate Great Magic Tricks — winner of the 2013 Euler Book Prize
Caveat emptor: Not sure if it's the right book, though. No author listed.
When probability works, it's because people made it work by removing influences that would throw off the calculations.
[1] https://www.atlasobscura.com/articles/dice-evolution-fate-fa...
From 25 trials?
Really, really fascinating life and experience.
If you let it bounce on a table, it's much more likely to land heavy-side down. Just imagine a very thick coin one side lead the other side balsa wood. That would land lead-side down much more than 50/50 if allowed to bounce on the table.
I had better dexterity as a child, and after hours I was able to flip a coin to 'heads' about 8/10 of the time. Same position, same muscle reflex, same results. I would proudly show my family my skill
Over time, I lost interest and the skill