Re: Another addition to formula

From Stanford Wong's BJ21


Posted by Pete Moss on 13 Jun 1998, 11:28 p.m., in response to Another addition to formula, posted by T-Hopper on 8 Jun 1998, 12:49 a.m.

When you take known removals into account, just about any system becomes "unbalanced", so the simplified formula goes out the window. Once I was asked what the insurance correlation for some count or another was. My reply, (something of a joke, actually), surprised some people. I asked, "For how many decks?" The known removal of an ace makes the correlation differ (but probably insignificantly so) depending on the number of decks.

Here's the code I wrote a couple of years ago. It could be made faster, but I haven't had any applications that needed to do correlations real fast.

double mdot(const SimpleCount &s1, const SimpleCount &s2, const Pack &pack)
{
double retval = 0;
double m1 = mean(s1,pack);
double m2 = mean(s2,pack);
for(int i=0;i<10;i++) {
retval += pack.N(i)*(s1.tag(i)-m1)*(s2.tag(i)-m2);
}
return retval;
}

// Given a known pack composition, and a count, return the mean
// value of the card tags in the deck.
double mean(const Pack &deck, const SimpleCount &count){
double retval = 0;
for(int i=0;i<10;i++) {
retval += deck.N(i)*count.tag(i);
}
return retval/deck.N();
}

// Figure the correlation of two counts, for a given (remaining) pack.
//
double correlation(const SimpleCount &s1,
const SimpleCount &s2,
const Pack &pack)
{
double d = mdot(s1,s1,pack)*mdot(s2,s2,pack);
if(d==0) return 0;
double retval = mdot(s1,s2,pack)/sqrt(d);
return retval;
}