Variance Equation

assume_R

Well-Known Member
#1
I will try to make this example as simple as I can :)

Bet $20, lose (-$20)
Bet $10, win (+$10)
Bet $15, double, win (+$30)

Total Money: +$20
Initial Wager: $45
Total Wager: $60

IBA: $20/$45 = +44.4%
TBA: $20/$60 = +33.3%

Average win: $6.67/hand


Here's my question:

Var = (1/3) * (400 + 100 + 900) - 6.67^2 = 422

I got that equation from Wikipedia.

Did I do that right and is that the variance per hand? Or do I divide by 3?
 
#2
Is This a Test? Cuz I Did Not Study!

Seems you are looking at variance after the fact?
There should be no variance after the fact?

Doesn't your sim program give you variance per hand or session?
I would think the variance per session or NO would be what matters?

:joker::whip:
 

assume_R

Well-Known Member
#3
Ha no test. I am trying to make my own sim program and want to know how to calculate variance. I will save how much us won and lost but I am a bit confused how to calculate the var per hour from that
 

sagefr0g

Well-Known Member
#4
assume_R said:
I will try to make this example as simple as I can :)

Bet $20, lose (-$20)
Bet $10, win (+$10)
Bet $15, double, win (+$30)

Total Money: +$20
Initial Wager: $45
Total Wager: $60

IBA: $20/$45 = +44.4%
TBA: $20/$60 = +33.3%

Average win: $6.67/hand


Here's my question:

Var = (1/3) * (400 + 100 + 900) - 6.67^2 = 422

I got that equation from Wikipedia.

Did I do that right and is that the variance per hand? Or do I divide by 3?
i believe the answer came out correct.
http://www.mathsisfun.com/data/standard-deviation.html
first find the average from the samples
then take each sample and find the difference of the sample from the average
then square each difference
add the squared difference's together
then divide that sum by the number of samples.
 

assume_R

Well-Known Member
#5
sagefr0g said:
i believe the answer came out correct.
http://www.mathsisfun.com/data/standard-deviation.html
first find the average from the samples
then take each sample and find the difference of the sample from the average
then square each difference
add the squared difference's together
then divide that sum by the number of samples.
Okay, so that would be the variance per hand? I suppose that's my real question. If I wanted the variance per hour, (100 hands), I'd multiply that number by 100?
 
#6
assume_R said:
Okay, so that would be the variance per hand? I suppose that's my real question. If I wanted the variance per hour, (100 hands), I'd multiply that number by 100?
First, great question.

Second, I probably have no idea as I wonder about this too.

But, what is wrong with assuming $1 bet per "round", you say "hand" maybe, but, to me, IBA would be $2/$3 or 66.66%. Like rounds played =3 but hands played =4. I guess TBA would be $2/$4=50%?

I mean would the fundamental advantage of the game change if one bet $1, $1 and $398 and win $796 over $400 initially bet?

In your example, if one lost all 3 "rounds", betting $'s as you describe, one has lost $60/rd*3 or $180, no? If one won all 3 rounds one has won $60*3, no? I just can't see how variance could be $400+/rd? I just can't see how variance/rd could exceed maximum possible loss/rd?

I realize you are playing BJ and maybe I am only playing some undefined game, as a starting point, wherein I win $1 33% of the time, lose $1 33% of the time and win $2 33% of the time. My avg bet is $1/rd.

All this, maybe, assuming $1 SD/rd? Otherwise, why re-invent the wheel since, in BJ, variance/rd changes slightly, I think, at every TC anyway?

I mean, in real BJ, one will have payoffs from -8 to +8 per "round" if one can split to 4 "hands" vs a single dealer upcard.

OTOH, you and Sagefrog could be completely correct as little as I know about how to figure this out.

But, to answer your question here, I do think variance is additive. Even if $variance/rd is different for 100 rounds due to different betting each round. $Variance after 100 rds is the sum of the $variance after each round.
 

Canceler

Well-Known Member
#7
Deetz said:
I just can't see how variance could be $400+/rd? I just can't see how variance/rd could exceed maximum possible loss/rd?
As it turns out, variance is not a particularly useful or meaningful number. It just happens to be a number you arrive at on the way to calculating standard deviation, which is more useful. (Standard deviation is the square root of variance.)
 

assume_R

Well-Known Member
#8
Yes, agreed. In my example the standard deviation would be just above $20. So how would one calculate variance to take into account splits? If that double was instead of a split, should one divide by 4 not 3? Or divide by the number of original (pre-split) hands?
 

sagefr0g

Well-Known Member
#9
assume_R said:
Okay, so that would be the variance per hand? I suppose that's my real question. If I wanted the variance per hour, (100 hands), I'd multiply that number by 100?
heh, heh, well i was just piping in, sorry i'm pretty much a lost puppy with this stuff, fun to talk about though.

errrhh, i sorta don't think so on multiplying by 100 for variance but if you converted the variance to standard deviation, then you could multiply the 100 by standard deviation per round to get your circa standard deviation per hour, sorta thing.
i think the problem is you square stuff to get variance from raw data, sorta thing, then you can get standard deviation from knowing the variance, but the variance calculation involves all that squaring mess. you square the data to get away from the problem of negative numbers messing up your differences, but then you are stuck with having squared stuff, lol.
i guess standard deviation kind of takes care of that problem and becomes a more useful number.:confused::whip:

edit: all the stuff in red is wrong, sorry it's like Sonny said: multiply by the square root of 100 for standard deviation per hour. geesh
http://www.blackjackinfo.com/bb/showpost.php?p=196837&postcount=11

variance is sigma squared (standard deviation= sigma) so standard deviation is the square root of variance.
 

sagefr0g

Well-Known Member
#10
assume_R said:
Yes, agreed. In my example the standard deviation would be just above $20. So how would one calculate variance to take into account splits? If that double was instead of a split, should one divide by 4 not 3? Or divide by the number of original (pre-split) hands?
just piping in again, lol, still confused, uncertain, lost.

i'd venture a guess, nope on divide by 4. you didn't do it on the double why do it on the split? the split could go to how many hands? three maybe? on each split, would be six? or whatever the rules allow.:confused::whip:

but to me (and i wouldn't be surprised if i'm wrong) say you get all this raw data from a simulation, sorta thing.
well, like when i look at sim's i see initial bet advantage being used and average initial bet. to me that's per round sorta stuff.:confused::whip: edit: seems that where the bet varies far as importance is where one employs a spread, sorta thing, not by the nature of the game which has splitting and doubling, snapper pays and insurance complications inherently, according to some normally distributed frequency, which would just be part of the raw data.
so whatever if you start out being interested in initial bet advantage and average initial bet then that's you focus of interest, so you lose some whopping amount on a split that splits and splits again, or so you make money on it, thing is that can still be related to the advantage of the initial bet sorta thing, on a round by round basis, i guess, i dunno, lol........ sorry for piping in, lol.
 

Sonny

Well-Known Member
#11
assume_R said:
I am trying to make my own sim program and want to know how to calculate variance.
It depends on what you are looking for. Some games, like craps, will have bets that are not resolved after one hand. In that case, you have to decide if you are looking for the variance per bet or the variance per round. For a game like BJ, everything is "settled up" after each hand so that is not a concern.

Ideally you would want to calculate the variance based on the exact probabilities of each payout, but with a sim you may not have that luxury. In many cases the variance will converge relatively quickly so sampling error becomes less of an issue. You can get some very accurate numbers from a good sim.

Your calculation looks correct. For a sim program, the technique is actually very simple. Just take the result of the hand, square it and add it to the running total. At the end of the sim you can divide that by the number of rounds played (or hands played) to get the average squared result. All you have to do is subtract the squared EV to get the variance.

Code:
do {
   old_bankroll = bankroll;

   //play the game here
   //make the payouts

   result = bankroll - old bankroll;
   variance += result * result;
   rounds++;

} while (rounds < rounds_to_play);

EV = bankroll / rounds;
variance = variance / rounds - EV * EV;
The nice thing about this method is that it includes the covariance of things like playing multiple hands or making side bets.

assume_R said:
Okay, so that would be the variance per hand? I suppose that's my real question. If I wanted the variance per hour, (100 hands), I'd multiply that number by 100?
Yup. Just make sure that you don't do that with the standard deviation though! You can't just multiply the SD by the number of hands the way you can with variance.

sqrt(422 * 100) != sqrt(422) * 100

assume_R said:
So how would one calculate variance to take into account splits? If that double was instead of a split, should one divide by 4 not 3?
It depends. This is one of those IBA vs. TBA decisions. Are you looking for the variance per round or the variance per hand? Most likely you will want your variance to match your EV calculations so you need to make sure that both are calculated the same way. Either is fine, but I believe the IBA and variance per round are more common.

-Sonny-
 

assume_R

Well-Known Member
#12
sagefrog, thanks for your thoughts, and thanks for your color-coded edits! haha.

Sonny said:
It depends. This is one of those IBA vs. TBA decisions. Are
you looking for the variance per round or the variance per hand? Most likely you will want your variance to match your EV calculations so you need to make sure that both are calculated the same way. Either is fine, but I believe the IBA and variance per round are more common.
Okay, so I suppose I have to decide whether to calculate variance per hand (in which case I'd treat each split separate), or variance per round (in which case I'd treat each split based on the initial bet). It seems the more logical choice would be to calculate the variance per round, since that would take into account covariance between split hands.

I guess it also gets a little bit complicated when one plays multiple hands at a certain count, and also splits, or doubles, etc. So if I played 2 hands at $50 each, and split one, I would have $150 on the table for that round. But my initial wager would be $100, which I'd use to calculate IBA. Then the variance would be calculated from how much my bankroll changed after an entire round is complete.

I'm fairly confident in my understanding of variance now. As long as I report the variance as "per round" or "per" some unit, I make sure I consider my average money won and bankroll change for that unit.

Gracias to all.
 
#13
since this topic is about what I want to know...

question:

Programs like "CVdata" or "PBA", does they show the covariance column ?

I mean covariance at each TC's.
 
#14
Sonny said:
Your calculation looks correct. For a sim program, the technique is actually very simple. Just take the result of the hand, square it and add it to the running total. At the end of the sim you can divide that by the number of rounds played (or hands played) to get the average squared result. All you have to do is subtract the squared EV to get the variance...-Sonny-
Thanks all for all the responses.

Sometimes I think maybe I'm getting it a little and then sometimes, in a flash, it dissipates into confusion again.

In the above what exactly does "EV" mean? I realize in orig example the avg actual $win was $6.67/round while varying bet. I guess based on actual $'s bet. What is wrong with calculating avg $EV as if he had bet $15/rd for 3 rounds. That gives an IBA of 66.67% or $10/round because he would have won $30 over the $45 initially bet/round? So, maybe, the $EV to square is $10?

If we have an unknown game from which all we know is we lose initial bet 33.3% of the time, win initial bet 33.3% of the time and win twice initial bet 33.3% of the time, ....

Confused again but that's OK :confused: :grin:
 

assume_R

Well-Known Member
#15
Alvaro said:
Programs like "CVdata" or "PBA", does they show the covariance column ?

I mean covariance at each TC's.
I know cvdata doesn't, and I'm not sure about pba. You can do it by hand if you know the variance at each count, then you just take the total_variance - 2 * variance_per_hand. But that doesn't take into account the change in count frequencies.

Deetz said:
Thanks all for all the responses.

In the above what exactly does "EV" mean? I realize in orig example the avg actual $win was $6.67/round while varying bet. I guess based on actual $'s bet. What is wrong with calculating avg $EV as if he had bet $15/rd for 3 rounds. That gives an IBA of 66.67% or $10/round because he would have won $30 over the $45 initially bet/round? So, maybe, the $EV to square is $10?
If I may explain, based on my current understanding, which I'm happy to say is more than it was a few days ago :)

If you want to know the variance, then you take how much money you won after a given round, and square it.

After summing all that up (400 + 100 + 900), you divide by the number of rounds (3).

This is key: since you are calculating the variance based on your money won per round, when you subtract a "mean", you must subtract the mean, or average "money won per round." They must be corresponding.

If we had summed the total $$ won after 1 hour, then squared it, and divided by the # of hours played, we would have to subtract the square of the average $$ / hour won. This would give you the variance per hour.

What it comes down to is: whatever you square, that's the "mean" you have to calculate.
 
Top