A calculation / simulation request
#1
Posted 2009-September-02, 04:07
Can someone who knows how to do these things help me determine the following please:
I'm looking for the expectation on the length of club suit when 1♣ is opened under the following conditions:
(1) 5+ clubs, 11-20HCP, no other 5-card suit (i.e. standard club openings)
and
(2) all 11-13 balanced hands (including 5♦332 but not 5M332)
and
(3) all 4♣441 11-20HCP hands
and
(4) all 17-19 balanced hands (except 5M332 and 5♦332)
Thanks in advance
Ant.
#2
Posted 2009-September-02, 04:55
2 13.65
3 26.40
4 28.84
5 19.45
6 9.29
7 2.09
8 0.26
9 0.02
The average club length was 3.92 with a standard error of 0.01
Code:
hcps = rep(c(rep(0,9),1,2,3,4),4)
clubs=c(rep(1,13),rep(0,39))
diamonds=c(rep(0,13),rep(1,13),rep(0,26))
hearts=c(rep(0,26),rep(1,13),rep(0,13))
spades=c(rep(0,39),rep(1,13))
mytable = array(dim=c(100000,5))
mycards=t(apply(array(1:100000),1,function(x)sample(52,13)))
mytable[,1] = apply(mycards,1,function(x)sum(hcps[x]))
mytable[,2] = apply(mycards,1,function(x)sum(clubs[x]))
mytable[,3] = apply(mycards,1,function(x)sum(diamonds[x]))
mytable[,4] = apply(mycards,1,function(x)sum(hearts[x]))
mytable[,5] = apply(mycards,1,function(x)sum(spades[x]))
balanced = (rowSums(mytable[,2:5]>1)==4) & (rowSums(mytable[,2:3]<6)==2) & (rowSums(mytable[,4:5]<5)==2)
noOther5cardsuit = rowSums(mytable[,3:5]>4)==0
antbalhands = balanced & ((((mytable[,1]>10) & (mytable[,1]<14)) | ((mytable[,1]>16) & (mytable[,1]<20))))
antunbalhands = !balanced & noOther5cardsuit & (mytable[,2] >3) & (mytable[,1]>10) & (mytable[,1]<21)
anthands = antbalhands | antunbalhands
sum(anthands) # Number of hands satisfying
round(table(mytable[anthands,2])*100/sum(anthands),2) # table
mean(mytable[anthands,2]) # mean
sd(mytable[anthands,2])/sqrt(sum(anthands)) # standard error
Edit: 5 minutes ago I posted a version where I forgot the HCP constraints un the unbalanced hands.
#3
Posted 2009-September-02, 05:37
Frequency :
2 118621
3 281226
4 287689
5 206532
6 84028
7 19084
8 2617
9 193
10 10
11 0
12 0
13 0
My code was:
(hcp(south)>=11 and
hcp(south)<=20 and
clubs(south)>=5 and
diamonds(south)<5 and
hearts(south)<5 and
spades(south)<5 and
not shape(south, any 5332)) or
(hcp(south)>=11 and
hcp(south)<=14 and
shape(south, any 4333 + any 4432 + any 5332) and
spades(south)<5 and
hearts(south)<5) or
(hcp(south)>=11 and
hcp(south)<=20 and
shape(south, any 4441) and
clubs(south)==4) or
(hcp(south)>=17 and
hcp(south)<=19 and
shape(south, any 4333 + any 4432 + any 5332) and
spades(south)<5 and
hearts(south)<5)
The run took 9 or 10 sec for 1000000 hands. Here is a second run:
Frequency :
2 118175
3 282014
4 287238
5 206442
6 84340
7 19060
8 2538
9 189
10 4
11 0
12 0
13 0
I believe that the USA currently hold only the World Championship For People Who Still Bid Like Your Auntie Gladys - dburn
dunno how to play 4 card majors - JLOGIC
True but I know Standard American and what better reason could I have for playing Precision? - Hideous Hog
Bidding is an estimation of probabilities SJ Simon
#4
Posted 2009-September-02, 05:54
Cascade, on Sep 2 2009, 06:37 AM, said:
hcp(south)<=20 and
clubs(south)>=5 and
diamonds(south)<5 and
hearts(south)<5 and
spades(south)<5 and
not shape(south, any 5332)) or
(hcp(south)>=11 and
hcp(south)<=14 and
shape(south, any 4333 + any 4432 + any 5332) and
spades(south)<5 and
hearts(south)<5) or
(hcp(south)>=11 and
hcp(south)<=20 and
shape(south, any 4441) and
clubs(south)==4) or
(hcp(south)>=17 and
hcp(south)<=19 and
shape(south, any 4333 + any 4432 + any 5332) and
spades(south)<5 and
hearts(south)<5)
The second condition was for 11-13 HCP, not 11-14.
As I read the conditions, balanced 5♦332 with 17-19 should not be included in the 1♣ openings.
#5
Posted 2009-September-02, 06:12
New Code:
(hcp(south)>=11 and
hcp(south)<=20 and
clubs(south)>=5 and
diamonds(south)<5 and
hearts(south)<5 and
spades(south)<5 and
not shape(south, any 5332)) or
(hcp(south)>=11 and
hcp(south)<=13 and
shape(south, any 4333 + any 4432 + any 5332) and
spades(south)<5 and
hearts(south)<5) or
(hcp(south)>=11 and
hcp(south)<=20 and
shape(south, any 4441) and
clubs(south)==4) or
(hcp(south)>=17 and
hcp(south)<=19 and
shape(south, any 4333 + any 4432 + any 5332) and
spades(south)<5 and
hearts(south)<5 and
diamonds(south)<5)
New Results (for two runs):
Frequency :
2 109433
3 261510
4 284520
5 223665
6 95877
7 21775
8 2988
9 225
10 7
11 0
12 0
13 0
Frequency :
2 109699
3 261357
4 284136
5 223636
6 96224
7 21767
8 2962
9 209
10 10
11 0
12 0
13 0
Maybe someone wants to invent a system to match my first conditions.
I believe that the USA currently hold only the World Championship For People Who Still Bid Like Your Auntie Gladys - dburn
dunno how to play 4 card majors - JLOGIC
True but I know Standard American and what better reason could I have for playing Precision? - Hideous Hog
Bidding is an estimation of probabilities SJ Simon
#6
Posted 2009-September-02, 07:26
Cascade, on Sep 2 2009, 07:12 AM, said:
lol
#7
Posted 2009-September-02, 10:17
Out of interest, what program(s) have you used? Is it / are they free?
I really feel I should be doing this myself, despite helpful and friendly people such as yourselves coming to my assistance!
#8
Posted 2009-September-02, 10:26
For example, for your first question, using a graphical interface I can specify 5+ clubs and 0-4 cards in diamonds, hearts, and spades and 11-20 HCP. Then I can ask for the odds of this hand type. The answer I get is 6.38% (which is probably right, but I can't make any promises!).
Fred Gitelman
Bridge Base Inc.
www.bridgebase.com
#9
Posted 2009-September-02, 10:27
As you can probably see at my code, the software has nothing to do with bridge but is a general-purpose statistical software.
#11
Posted 2009-September-02, 11:52
As for tv, screw it. You aren't missing anything. -- Ken Berg
Our ultimate goal on defense is to know by trick two or three everyone's hand at the table. -- Mike777
I have come to realise it is futile to expect or hope a regular club game will be run in accordance with the laws. -- Jillybean
#12
Posted 2009-September-02, 13:33
TimG, on Sep 3 2009, 04:45 AM, said:
Ant590, on Sep 2 2009, 11:17 AM, said:
I use Dealer. It is free and can be found here.
Me too.
I believe that the USA currently hold only the World Championship For People Who Still Bid Like Your Auntie Gladys - dburn
dunno how to play 4 card majors - JLOGIC
True but I know Standard American and what better reason could I have for playing Precision? - Hideous Hog
Bidding is an estimation of probabilities SJ Simon
#13
Posted 2009-September-02, 13:38
fred, on Sep 3 2009, 04:26 AM, said:
For example, for your first question, using a graphical interface I can specify 5+ clubs and 0-4 cards in diamonds, hearts, and spades and 11-20 HCP. Then I can ask for the odds of this hand type. The answer I get is 6.38% (which is probably right, but I can't make any promises!).
Fred Gitelman
Bridge Base Inc.
www.bridgebase.com
It seems to be exactly what I get - 0.063759347
I believe that the USA currently hold only the World Championship For People Who Still Bid Like Your Auntie Gladys - dburn
dunno how to play 4 card majors - JLOGIC
True but I know Standard American and what better reason could I have for playing Precision? - Hideous Hog
Bidding is an estimation of probabilities SJ Simon
#14
Posted 2009-September-02, 15:24
#15
Posted 2009-September-03, 09:29
In dealer, I can run the file, and I generate 40 hands, but if I add something like -p 100 to the end to try and get more or fewer deals I get a bus error. I'm also unsure of how to run an input file.
Help!
#16
Posted 2009-September-03, 10:52
However, it doesn't seem to be able to nestle logical commands.
I.e. I can't write a statement like
{[spades north]<=4 || {[balanced north]&&[hearts north]==4}}
Any ideas what I'm doing wrong?
#17
Posted 2009-September-03, 12:58
Ant590, on Sep 3 2009, 05:52 PM, said:
However, it doesn't seem to be able to nestle logical commands.
I.e. I can't write a statement like
{[spades north]<=4 || {[balanced north]&&[hearts north]==4}}
Any ideas what I'm doing wrong?
It should be
{[spades north]<=4 || ([balanced north]&&[hearts north]==4)}
#18
Posted 2009-September-03, 13:06
The TCL programming language that deal uses is extremely sensitive to correct blanks and TCL is case sensitive.
Expressions are some what unusual.
So you better split that condition to:
if { [spades north] <= 4 }
{
if { [balanced north] && [hearts north] == 4 }
{
Do your thing here!
}
}

Help
