BBO Discussion Forums: A calculation / simulation request - BBO Discussion Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

A calculation / simulation request

#1 User is offline   Ant590 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 749
  • Joined: 2005-July-17
  • Gender:Male
  • Location:Melbourne, Australia

Posted 2009-September-02, 04:07

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 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.
0

#2 User is offline   helene_t 

  • The Abbess
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 17,401
  • Joined: 2004-April-22
  • Gender:Female
  • Location:Odense, Denmark
  • Interests:History, languages

Posted 2009-September-02, 04:55

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.
The world would be such a happy place, if only everyone played Acol :) --- TramTicket
0

#3 User is offline   Cascade 

  • PipPipPipPipPipPipPipPip
  • Group: Yellows
  • Posts: 6,772
  • Joined: 2003-July-22
  • Gender:Male
  • Location:New Zealand
  • Interests:Juggling, Unicycling

Posted 2009-September-02, 05:37

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
Wayne Burrows

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 User is offline   TimG 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 3,972
  • Joined: 2004-July-25
  • Gender:Male
  • Location:Maine, USA

Posted 2009-September-02, 05:54

Cascade, on Sep 2 2009, 06:37 AM, said:

(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 5♦332 with 17-19 should not be included in the 1♣ openings.
0

#5 User is offline   Cascade 

  • PipPipPipPipPipPipPipPip
  • Group: Yellows
  • Posts: 6,772
  • Joined: 2003-July-22
  • Gender:Male
  • Location:New Zealand
  • Interests:Juggling, Unicycling

Posted 2009-September-02, 06:12

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.
Wayne Burrows

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 User is offline   rbforster 

  • PipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 1,611
  • Joined: 2006-March-18

Posted 2009-September-02, 07:26

Cascade, on Sep 2 2009, 07:12 AM, said:

Maybe someone wants to invent a system to match my first conditions.

lol ;)
0

#7 User is offline   Ant590 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 749
  • Joined: 2005-July-17
  • Gender:Male
  • Location:Melbourne, Australia

Posted 2009-September-02, 10:17

Thank you both very much indeed.

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!
0

#8 User is offline   fred 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 4,616
  • Joined: 2003-February-11
  • Gender:Male
  • Location:Las Vegas, USA

Posted 2009-September-02, 10:26

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
0

#9 User is offline   helene_t 

  • The Abbess
  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 17,401
  • Joined: 2004-April-22
  • Gender:Female
  • Location:Odense, Denmark
  • Interests:History, languages

Posted 2009-September-02, 10:27

I use R. You can download it from http://cran.r-project.org/

As you can probably see at my code, the software has nothing to do with bridge but is a general-purpose statistical software.
The world would be such a happy place, if only everyone played Acol :) --- TramTicket
0

#10 User is offline   TimG 

  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 3,972
  • Joined: 2004-July-25
  • Gender:Male
  • Location:Maine, USA

Posted 2009-September-02, 10:45

Ant590, on Sep 2 2009, 11:17 AM, said:

Out of interest, what program(s) have you used? Is it / are they free?

I use Dealer. It is free and can be found here.
0

#11 User is offline   blackshoe 

  • PipPipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 18,067
  • Joined: 2006-April-17
  • Gender:Male
  • Location:Rochester, NY

Posted 2009-September-02, 11:52

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?
--------------------
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
0

#12 User is offline   Cascade 

  • PipPipPipPipPipPipPipPip
  • Group: Yellows
  • Posts: 6,772
  • Joined: 2003-July-22
  • Gender:Male
  • Location:New Zealand
  • Interests:Juggling, Unicycling

Posted 2009-September-02, 13:33

TimG, on Sep 3 2009, 04:45 AM, said:

Ant590, on Sep 2 2009, 11:17 AM, said:

Out of interest, what program(s) have you used? Is it / are they free?

I use Dealer. It is free and can be found here.

Me too.
Wayne Burrows

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 User is offline   Cascade 

  • PipPipPipPipPipPipPipPip
  • Group: Yellows
  • Posts: 6,772
  • Joined: 2003-July-22
  • Gender:Male
  • Location:New Zealand
  • Interests:Juggling, Unicycling

Posted 2009-September-02, 13:38

fred, on Sep 3 2009, 04:26 AM, said:

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
Wayne Burrows

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 User is offline   gnasher 

  • Andy Bowles
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 11,993
  • Joined: 2007-May-03
  • Gender:Male
  • Location:London, UK

Posted 2009-September-02, 15:24

I use Thomas Andrews's "Deal". It's free, and is available for both PC and Mac.
... that would still not be conclusive proof, before someone wants to explain that to me as well as if I was a 5 year-old. - gwnn
0

#15 User is offline   Ant590 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 749
  • Joined: 2005-July-17
  • Gender:Male
  • Location:Melbourne, Australia

Posted 2009-September-03, 09:29

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!
0

#16 User is offline   Ant590 

  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 749
  • Joined: 2005-July-17
  • Gender:Male
  • Location:Melbourne, Australia

Posted 2009-September-03, 10:52

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?
0

#17 User is offline   gnasher 

  • Andy Bowles
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 11,993
  • Joined: 2007-May-03
  • Gender:Male
  • Location:London, UK

Posted 2009-September-03, 12:58

Ant590, on Sep 3 2009, 05:52 PM, said:

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)}
... that would still not be conclusive proof, before someone wants to explain that to me as well as if I was a 5 year-old. - gwnn
0

#18 User is offline   hotShot 

  • Axxx Axx Axx Axx
  • PipPipPipPipPipPipPip
  • Group: Advanced Members
  • Posts: 2,976
  • Joined: 2003-August-31
  • Gender:Male

Posted 2009-September-03, 13:06

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!
}
}
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users