Posted 2007-September-08, 05:32
Because the alternative was revising liquidity management, I had a look at the Excel code you quoted.
The hands it is generating look more or less OK, but as others have pointed out where you are going wrong is when you sort the hands & suits, as you end up double-counting some distributions.
I took your code and generated 5000 hands from it.
[side note: it will work much faster if you turn off screenupdating at the start, turn it on at the end, and use the status bar to show progress rather than a cell]
However, I removed the sorting part in the sort_suit and sort_hand subroutines, so that the 'distributions' sheet kept the suits in order clubs, diamonds, hearts, spades; and the hands in order 1,2,3,4.
I then did my own summary formulae in Excel (could have put this into the macro but I hate fiddling with other people's code) which counted the size of the club fit between the first two hands - so in the Distributions sheet it had another column filled down with "=MID($A2,2,1)+MID($B2,2,1)"
The next column had the break of the spade suit between the two remaining hands
"=MID($C2,2,1) & "-" & MID($D2,2,1)"
So, for example, the first deal was
.AKJT9.32.T65432 JT5432..T974.QJ7 AKQ76.Q652.J865. 98.8743.AKQ.AK98
the first cell of the first column of my summay is 9 (the first two hands have a 9-card club fit); the first cell of the second column of my summary is 0-4 (because the remaining clubs are split 0-4 between the other two hands).
I counted how many 9-card club fits there were in 5000 deals (353 in this case), and counted how many times the break was 2-2, 1-3, 3-1, 0-4, 4-0. The answers came to 43%, 49%, 8%.
I repeated for diamonds, hearts and spades and the overall percentages were excatly 40%, 50% and 10%.
I then didn't look just at the size of the fit, but at how the fit was formed ("=MID($A2,2,1) & "-" & MID($B2,2,1)"
For 4-5 or 5-4 fits I got 40%, 51%, 9%
For 3-6 or 6-3 fits I got 42%, 49%, 10%
Try this or something similar i.e. try taking the raw output from your program without doing the sorting first and seeing what you get - when you get a different answer, have a think about the effect your sorting into descending order is having.