RTP, house edge and expected loss: the three numbers behind every casino game, in code
Every casino game page prints a percentage called RTP. Most players read it as "how much I get back". It is closer to "how much the game keeps from everything you bet, on average, over a very long time". This post turns the three related numbers into a few lines of JavaScript and shows why the per-bet figure looks small while the session figure does not.
Three names for one fact
- RTP (return to player): the share of all money wagered that the game pays back over the long run. 97% means 97 of every 100 staked come back, spread unevenly over all players and all rounds.
- House edge: what is left.
edge = 1 - RTP, so 97% RTP is a 3% edge. - Expected loss: the edge applied to the money you actually put through the game.
const edge = (rtp) => 1 - rtp const expectedLoss = (stake, bets, rtp) => stake * bets * edge(rtp) Turnover, not deposit
The trap is in the middle factor. Expected loss grows with turnover (stake times number of bets), not with the amount you brought. A player with 50 who plays 1 per round for 400 rounds has turned over 400, not 50.
expectedLoss(1, 400, 0.97) // 12 -> 3% of 400 expectedLoss(1, 400, 0.99) // 4 -> 1% of 400 Winnings that are bet again count again. That is why a session can end below the starting balance even when it "felt" even: the same coins went through the edge many times.
Small differences, large sessions
Two versions of the same game can carry different RTPs. Studios often ship several, and a casino picks one. Over a long session the gap is not small:
const rounds = 2000, stake = 0.5 for (const rtp of [0.99, 0.97, 0.95]) { console.log(rtp, expectedLoss(stake, rounds, rtp).toFixed(2)) } // 0.99 10.00 // 0.97 30.00 // 0.95 50.00 Same game, same player, same 2,000 rounds: the 95% version costs five times what the 99% version costs on average.
What expected loss does not tell you
It is an average. One session can end far above or far below it, and high-volatility games swing more around it. It says nothing about the next round, and no betting pattern changes it: doubling after a loss, for example, only raises the turnover and therefore the expected loss.
// Martingale does not change the edge, it changes the turnover const flat = expectedLoss(1, 100, 0.97) // 3.00 const doubled = expectedLoss(1.8, 100, 0.97) // 5.40 when the average stake grows to 1.8 Try it with your own numbers
I put the same formula into a small free calculator that also lets you lock the RTP of a specific crash or instant game title: expected loss calculator. It runs in the browser, no sign-up.
The short version: RTP is a long-run return on turnover, the edge is its complement, and the cost of a session is the edge times everything you put through the game, including the money you won and bet again.
Written with the help of an AI assistant; the formulas and every number above were checked by hand.