Jump to content

A calculation / simulation request


Recommended Posts

Hi,

 

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 5332 but not 5M332)

and

(3) all 4441 11-20HCP hands

and

(4) all 17-19 balanced hands (except 5M332 and 5332)

 

Thanks in advance

Ant.

Link to comment
Share on other sites

100000 simulations gave 17400 hands satisfying the criteria, the percentages for club lengths were

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.

Link to comment
Share on other sites

Here is what I got from dealer:

 

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

Link to comment
Share on other sites

(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 second condition was for 11-13 HCP, not 11-14.

 

As I read the conditions, balanced 5332 with 17-19 should not be included in the 1 openings.

Link to comment
Share on other sites

Well spotted these things happen when you do this sort of stuff near midnight.

 

 

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.

Link to comment
Share on other sites

The next version of the web-client will be able to answer these questions in a relatively easy way.

 

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

Link to comment
Share on other sites

I'm lazy - and I haven't done any real programming in years. So I tend to look for Mac binaries for things like this. There is one for R, so I downloaded that. Now the question is whether I can learn R well enough to use it. I suppose I could download the Dealer source code, and see if I can get a Mac executable out of that, but for me that would be a lot of work - especially undesirable if somebody else has already done it. Anyone know if anyone has?
Link to comment
Share on other sites

The next version of the web-client will be able to answer these questions in a relatively easy way.

 

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

Link to comment
Share on other sites

Well, I've had a go with deal and dealer and I'm stuck on them both!

 

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!

Link to comment
Share on other sites

Meanwhile I'm making much more progress with deal.

 

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?

Link to comment
Share on other sites

Meanwhile I'm making much more progress with deal.

 

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)}

Link to comment
Share on other sites

Edit: Andy's suggestion is better!

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!

}

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...