sleepyeyed
sleepyeyed
  • Threads: 2
  • Posts: 6
Joined: Dec 12, 2013
November 10th, 2017 at 11:53:30 AM permalink
I've been very interested in the dice sites that use bitcoin for their deposits and I've found a particularly decent one that I've been able to generate a small profit from. I'm not much of a math guy so I'm wondering what my risk of ruin is in the following scenario.

Bankroll = .00850000 BTC
Win chance = 9%
Payout = 11x
Base bet = .00000005 BTC
On loss increase bet by 12%

So how many bets will I have to lose in a row in order to kill my bankroll and what are the odds of that happening?
ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6302
Joined: Jun 22, 2011
November 11th, 2017 at 8:34:24 AM permalink
Question: when you win, what happens to your bet?
(a) Back to the initial bet (50 nanoBTCs)
(b) Stay the same as the previous bet
(c) Reduce the bet by 12%

Next question: at which point (either bankroll, or total number of bets) do you stop? Without a stop condition, you will lose 100% of the time.

Also, I am assuming the payout includes the initial bet (i.e. it pays 10-1) - if it pays 11-1, you have an 8% edge (in every 100 bets, you are expected to win 11 9 times, and lose 1 91 times).

The number of bets you need to lose in a row from the start in order to lose the entire bankroll (and just to clarify, your bankroll is 170,000 times your initial bet, correct?) is about 57; this has a 1/216 chance of happening.
Correction - that is for increasing the bet by 20% each time; for 12%, this is 88 consecutive bets, which is about 1 / 4020
Last edited by: ThatDonGuy on Nov 11, 2017
sleepyeyed
sleepyeyed
  • Threads: 2
  • Posts: 6
Joined: Dec 12, 2013
November 11th, 2017 at 9:04:11 AM permalink
On a win you go back to initial bet.
ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6302
Joined: Jun 22, 2011
November 11th, 2017 at 2:48:06 PM permalink
I don't know if there's a formula to determine the average number of bets it will take to lose the entire bankroll if the bet can change.

I ran a simulation, and it is usually around 350,000 bets, but then you get that one really long run that raises the number significantly.

The probability of losing everything is 100% unless you have stopping conditions (for example, "stop after 10,000 bets," or, "stop when my bankroll doubles"). I can't determine the probability without knowing when you will stop.
sleepyeyed
sleepyeyed
  • Threads: 2
  • Posts: 6
Joined: Dec 12, 2013
November 12th, 2017 at 5:52:07 AM permalink
stopping at double bankroll would be the goal. Thanks for the clarification.
ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6302
Joined: Jun 22, 2011
November 13th, 2017 at 8:55:00 AM permalink
Can somebody check my numbers on this one?
Either (a) there is a glaring error in my simulating code that I can't find, (b) the RNG is off (which I doubt), or (c) given the conditions, the bankroll will double somewhere around 52% of the time. Now, keep in mind that it takes on average 40,000 bets to double the bankroll, as opposed to about 10,000 bets to lose the whole thing. but still, this seems to contradict the "no systems work" thought.

Here are the conditions I am using:
The initial bankroll is 170,000
The initial bet is 1
Each bet has a 9% chance of winning, and pays off at 10-1; this is a HA of 1% (in 100 bets, 9 win = +90, and 91 lose = -91, for a net loss of 1 per 100 bet)
The bet is increased by 12%, rounded to the nearest 0.0001, after each loss, and is reset to 1 after each win; if the bet becomes greater than the bankroll, bet the entire bankroll
Continue until the bankroll is doubled or zero

When I run my simulator with a straight Martingale, it loses well over 50% of the time.
However, when I run it with these conditions, over a total of 1 billion bets (not one billion final results, note), it wins slightly more than 51% of the time.
Note that the higher the initial bankroll, the more likely you are to double up; pretty much any initial bankroll over 40,000 doubles up more than 50% of the time, and at around 130,000, it reaches 51%.
OnceDear
OnceDear
  • Threads: 63
  • Posts: 7478
Joined: Jun 1, 2014
November 13th, 2017 at 11:16:37 AM permalink
Quote: ThatDonGuy

Can somebody check my numbers on this one?
Either (a) there is a glaring error in my simulating code that I can't find, (b) the RNG is off (which I doubt), or (c) given the conditions, the bankroll will double somewhere around 52% of the time. Now, keep in mind that it takes on average 40,000 bets to double the bankroll, as opposed to about 10,000 bets to lose the whole thing. but still, this seems to contradict the "no systems work" thought.

Here are the conditions I am using:
The initial bankroll is 170,000
The initial bet is 1
Each bet has a 9% chance of winning, and pays off at 10-1; this is a HA of 1% (in 100 bets, 9 win = +90, and 91 lose = -91, for a net loss of 1 per 100 bet)
The bet is increased by 12%, rounded to the nearest 0.0001, after each loss, and is reset to 1 after each win; if the bet becomes greater than the bankroll, bet the entire bankroll
Continue until the bankroll is doubled or zero

When I run my simulator with a straight Martingale, it loses well over 50% of the time.
However, when I run it with these conditions, over a total of 1 billion bets (not one billion final results, note), it wins slightly more than 51% of the time.
Note that the higher the initial bankroll, the more likely you are to double up; pretty much any initial bankroll over 40,000 doubles up more than 50% of the time, and at around 130,000, it reaches 51%.

Hi TDG,
If the only possible outcomes are double or lose all, then the probability should be well shy of 50% because of amount of action facing the house edge. So you are in the right ball park, but too high. Are you constraining the last bet so that you cannot possibly do more than double bankroll? If not, then we should expect significantly less probability of success.
P>50%, must mean you are doing something wrong, or else you have found the philosopher's stone.
First thing that came to mind was that you might be paying out 11 instead of 10.
Can we see your simulation code or pseudo-code?
Psalm 25:16 Turn to me and be gracious to me, for I am lonely and afflicted. Proverbs 18:2 A fool finds no satisfaction in trying to understand, for he would rather express his own opinion.
ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6302
Joined: Jun 22, 2011
November 13th, 2017 at 12:28:04 PM permalink
Quote: OnceDear

Hi TDG,
If the only possible outcomes are double or lose all, then the probability should be well shy of 50% because of amount of action facing the house edge. So you are in the right ball park, but too high. Are you constraining the last bet so that you cannot possibly do more than double bankroll? If not, then we should expect significantly less probability of success.
P>50%, must mean you are doing something wrong, or else you have found the philosopher's stone.
First thing that came to mind was that you might be paying out 11 instead of 10.
Can we see your simulation code or pseudo-code?


Here it is:


long NumBets = 0L; // The number of bets made
long NumRuns = 0L; // The number of "runs" (from the starting point to double or bust)
long NumWins = 0L; // The number of runs where the bankroll was double

// The bankroll is 170,000 times the initial bet
long InitialBankroll = 170000000L;
long Bet = 1000L;

long Bankroll = InitialBankroll;

// This is the main loop - "Running" is a boolean variable that is normally true
while (Running)
{
// R.Next(100) returns a uniform random integer from 0 to 99 inclusive

if (R.Next(100) < 9)
{
// Bet wins - pay at 10-1

Bankroll += (Bet * 10L);

// If the bankroll is now at least twice what it started as, count it as a win,
// and reset the bankroll to its initial amount

if (Bankroll >= 2L * InitialBankroll)
{
Bankroll = InitialBankroll;
NumRuns++;
NumWins++;
}

// Reset the bet to its initial amount after any win

Bet = 1000L;
}
else
{
// Bet loses - increase bet by 12%, rounded to the nearest unit

Bankroll -= Bet;
Bet = (Bet * 56L + 25L) / 50L;

// If the revised bet exceeds the bankroll, bet the bankroll instead

if (Bet > Bankroll)
{
Bet = Bankroll;
}

// If the bankroll is zero, count it as a loss, and reset the bankroll
// and bets to their initial amounts

if (Bankroll <= 0L)
{
NumRuns++;
Bankroll = InitialBankroll;
Bet = 1000L;
}
}
NumBets++;
}


sleepyeyed
sleepyeyed
  • Threads: 2
  • Posts: 6
Joined: Dec 12, 2013
November 13th, 2017 at 2:42:00 PM permalink
I'm not a coder by any means, but it seems that you're basing bets on 0-99 instead of 0-99.9999. Could that affect the outcome?
Romes
Romes
  • Threads: 29
  • Posts: 5604
Joined: Jul 22, 2014
November 13th, 2017 at 3:04:27 PM permalink
I half cheated and copied your code in to a javascript simulation I have for blank quick stuff... modified your code for myself, and reran... I have a bug, where I'm running for 100,000 trials, but somehow the NumRuns variable ended at 110,000.

If it actually ran 100,000 trails only, then I'm also showing the Win% at ~52%.

HOWEVER, I suspect this NumRuns issue is the culprit... if I take the wins (52,366) out of the 110,000 runs, then I come up with a win% of 47.6%.

I also know this is a smaller number than I should run, but the computer I'm on now is nothing like my home computer, so it actually took 3min 30 seconds to just run the 100,000 (or 110,000)... Lastly, I'm not claiming this is the most efficient version of the code, but it's quick, dirty, and I tried to be exceedingly simple to avoid error while doing this as fast as possible.

I'll report more when the bug is found.



function runSimulation(){
numTrials = document.getElementById("numberOfTrials").value;


//Run for X number of trails
while (numTrials > 0)
{
//Each trial takes numerous bets to resolve (seems ~50k is the double up point of success)
while (currentSimulation)
{
//Random integer from 1 to 100 inclusive
currentResult = parseInt((Math.random()*100)+1, 10)

if (currentResult <= 9)
{
//Winning bet is paid 10-1 (i.e. $10 wager would be paid $100... Bet*10)
bankroll = bankroll + (Bet * 10);

//If the bankroll reaches the win goal, update globals and reset to run again
if (bankroll >= winGoal)
{
bankroll = initialBankroll;
NumRuns++;
NumWins++;
currentSimulation = false;
}

//Always reset bet after a win
Bet = 1;
}
else
{
//Losing bet: deduct from BR then up the next bet by 12%
bankroll = bankroll - Bet;
Bet = Bet + (Bet * .12)

//If new bet is more than current bankroll, just bet current bankroll
if (Bet > bankroll)
{
Bet = bankroll;
}

//If the bankroll is zero, count it as a loss, and reset the bankroll
//and bets to their initial amounts
if (bankroll <= 0)
{
NumRuns++;
bankroll = initialBankroll;
Bet = 1
currentSimulation = false;
}
}

NumBets++;
}


numTrials--;
currentSimulation = true;
}

//Update Results Here
alert('Number of Runs: ' + NumRuns);
alert('Number of Bets: ' + NumBets);
alert('Number of Wins = ' + NumWins);
alert('Won ' + NumWins + ' out of ' + NumRuns + ' trials.');
}

Playing it correctly means you've already won.
Romes
Romes
  • Threads: 29
  • Posts: 5604
Joined: Jul 22, 2014
November 14th, 2017 at 8:26:32 AM permalink
Bug found... I wasn't resetting the global variables... Since I was doing a quick dirty javascript behind an html page, it ran like a web app, but it kept the previous totals (since it's not a web app and doesn't have an on page load reset) and kept running. I ran for a 10,000 trial run to see how long it would take, then ran for a 100,000 trial run, so it added all of the results together.

Thus, I'm getting a hair over 47% as the final return for the bankroll on a 100,000 trial run (repeated again).

NumRuns = 100,000
NumBets = 3,001,604,527
NumWins = 47,308

47.6% last 100k run.
47.3% this 100k run.

One more for good measure for now, but at lunch I'll run a 1,000,000 trial run (which should take ~35 minutes to run). Though, I'm fairly sold the numbers are converging on a ~47.5% win ratio.

NumRuns = 100,000
NumBets = 3,004,395,329
NumWins = 47,624

47.6% most recent 100k run.
Playing it correctly means you've already won.
mustangsally
mustangsally
  • Threads: 25
  • Posts: 2463
Joined: Mar 29, 2011
November 14th, 2017 at 10:39:57 AM permalink
Quote: sleepyeyed

stopping at double bankroll would be the goal. Thanks for the clarification.

Just to add, IF you continue playing even after double your start bankroll, just a matter of time before you lose it all.
that probability = 1 when playing against a house edge.
still could be lots of fun

*****
here are 10 games I played (in R)
and the results.
bummer, won 3 lost 7

> # initialize parameters
> init_start <- 170000
> init_goal <- init_start * 2
> init_bet <- 1 # initial bet value
> prob_win <- 9/100 # probability of win
> n <- 1 # simulation count
> bet_increase <- 1.12 # bet increase after a loss (factor)
> payoff_odds <- 10 # payoff odds on win
<snip code - boring>

Results:
Win probability: 1
Lose probability: 0
games played: 52044

Win probability: 0
Lose probability: 1
games played: 9265

Win probability: 0
Lose probability: 1
games played: 40029

Win probability: 0
Lose probability: 1
games played: 37898

Win probability: 0
Lose probability: 1
games played: 22212

Win probability: 1
Lose probability: 0
games played: 50108

Win probability: 0
Lose probability: 1
games played: 15390

Win probability: 0
Lose probability: 1
games played: 1342

Win probability: 1
Lose probability: 0
games played: 41080

Win probability: 0
Lose probability: 1
games played: 29777


Bold play (bet just enough to hit target on next game or bet it all)
imo
would win more often (49.6% probability to double up)
and not take that much time (bets) to double up

sounds like more fun to me

example:
start with 17000 bet
if lose
bank=153000
next bet = 18700
and so on
easy to calculate too
> pdoub = function(br,goal,max_bet,pwin,odds,thresh,prob=1) {
+ if (br < 1 | prob < thresh) return(0)
+ bet = ceiling((goal-br)/odds) # bet needed to reach goal
+ limit = min(br,max_bet) # limit = max bet possible
+ if ( bet < limit )
+ pwin + (1-pwin)*pdoubb(br-bet,goal,max_bet,pwin,odds,thresh,prob*(1-pwin))
+ else
+ pwin*pdoubb(br+odds*limit,goal,max_bet,pwin,odds,thresh,prob*pwin) + (1-pwin)*pdoubb(br-limit,goal,max_bet,pwin,odds,thresh,prob*(1-pwin))
+ }
> require(compiler)
Loading required package: compiler
> pdoubb = cmpfun(pdoub)
> p <- pdoubb(170000,340000,100000,9/100,10,0.0000001)
> p
[1] 0.4962278


may play that later.
have fun!
fun thread
Sally
I Heart Vi Hart
ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6302
Joined: Jun 22, 2011
November 14th, 2017 at 11:53:40 AM permalink
I think I found my problem...apparently, it is with .NET's RNG. I think it is just a little too regular. When I switched it to one that I wrote, I now get 47.1%.
Romes
Romes
  • Threads: 29
  • Posts: 5604
Joined: Jul 22, 2014
November 14th, 2017 at 12:23:37 PM permalink
Quote: ThatDonGuy

I think I found my problem...apparently, it is with .NET's RNG. I think it is just a little too regular. When I switched it to one that I wrote, I now get 47.1%.

That's interesting that different RNG's are giving different results. Shows you just how "random" they are I guess:

1) .NET RNG = 52%
2) JavaScript Math.Random = 47.6%
3) TDG's RNG = 47.1%

I've run nearly half a million trials on simulation and they're all converging to 47% essentially. Pretty sure that's our answer.
Playing it correctly means you've already won.
  • Jump to: