# Did some statistical programming

Discussion in 'NHL Draft - Prospects' started by Potted Plant, Jul 13, 2005.

Not open for further replies.
1. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
Alright, I wasted a lot of time I should have spent studying for the Bar, but I took this as a personal challenge. If TSN is right about who gets how many balls, here is the breakdown.

The three-ball teams have the following percentage changes of getting certain picks:

1 6.1545
2 6.0535
3 5.895
4 5.671
5 5.516
6 5.439
7 5.3185
8 5.0285
9 4.865
10 4.765
11 4.4885
12 4.1545
13 4.0665
14 3.8075
15 3.617
16 3.5475
17 3.198
18 2.8485
19 2.6625
20 2.461
21 2.2215
22 1.996
23 1.6375
24 1.3265
25 1.1365
26 0.8215
27 0.6025
28 0.3915
29 0.2265
30 0.0825

The two-ball teams have these percentages:

1 4.288
2 4.083
3 4.079
4 4.1315
5 4.0755
6 4.1515
7 4.031
8 4.099
9 4.0795
10 3.9975
11 3.917
12 3.9715
13 3.933
14 3.914
15 3.8215
16 3.705
17 3.5355
18 3.714
19 3.416
20 3.376
21 3.258
22 3.194
23 2.8765
24 2.737
25 2.5085
26 2.1495
27 1.87
28 1.517
29 1.041
30 0.5295

The one-ball teams are as follows:

1 2.153
2 2.18
3 2.135
4 2.1325
5 2.252
6 2.3445
7 2.4475
8 2.4535
9 2.474
10 2.6045
11 2.62
12 2.713
13 2.829
14 2.772
15 2.9055
16 3.007
17 3.166
18 3.2185
19 3.4925
20 3.582
21 3.632
22 3.8195
23 4.073
24 4.2555
25 4.466
26 4.7345
27 4.9995
28 5.154
29 5.603
30 5.781

Your 50% marks are as follows:

3-ball teams: there is a 50% chance you will get the 9th pick or higher.
2-ball teams: there is a 50% chance you will get the 13th pick or higher
1-ball teams: there is a 50% chance you'll get the 20th pick or higher

Enjoy

Joined:
Feb 27, 2002
Messages:
8,321
31
Trophy Points:
146
Location:
Awesome work!

Thanks

3. ### al3xRegistered User

Joined:
Jul 12, 2005
Messages:
239
0
Trophy Points:
74
Occupation:
student
Location:
Bucharest,Romania
nice...

4. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
BTW, here is the visual basic program I used.

Private Sub Draft()

Dim i, j, k, var, Rand As Integer
Dim x(49) As Integer
Dim One1(30) As Integer
Dim Two2(30) As Integer
Dim Three3(30) As Integer

Randomize
origin = 1
For k = 1 To 30 Step 1
One1(k) = 0
Two2(k) = 0
Three3(k) = 0
Next k

For i = 1 To 200000 Step 1
x(1) = 4
x(2) = 3
x(3) = 5
x(4) = 4
x(5) = 3
x(6) = 5
x(7) = 4
x(8) = 3
x(9) = 5
x(10) = 4
x(11) = 3
x(12) = 5
x(13) = 1
x(14) = 2
x(15) = 1
x(16) = 2
x(17) = 1
x(18) = 2
x(19) = 1
x(20) = 2
x(21) = 1
x(22) = 2
x(23) = 1
x(24) = 2
x(25) = 1
x(26) = 2
x(27) = 1
x(28) = 2
x(29) = 1
x(30) = 2
x(31) = 1
x(32) = 2
x(33) = 0
x(34) = 0
x(35) = 0
x(36) = 0
x(37) = 0
x(38) = 0
x(39) = 0
x(40) = 0
x(41) = 0
x(42) = 0
x(43) = 0
x(44) = 0
x(45) = 0
x(46) = 0
x(47) = 0
x(48) = 0
x(49) = 6

For j = 1 To 30 Step 1
var = 49
Do Until x(var) <> 6
var = Int(48# * Rnd) + 1
Loop
If (x(var) = 3) Then
x(var - 1) = 6
x(var + 1) = 6
ElseIf (x(var) = 4) Then
x(var + 1) = 6
x(var + 2) = 6
ElseIf (x(var) = 5) Then
x(var - 1) = 6
x(var - 2) = 6
ElseIf (x(var) = 2) Then x(var - 1) = 6
ElseIf (x(var) = 1) Then x(var + 1) = 6
End If
x(var) = 6
If (var = 1) Or (var = 2) Or (var = 3) Then Three3(j) = Three3(j) + 1
If (var = 13) Or (var = 14) Then Two2(j) = Two2(j) + 1
If (var = 33) Then One1(j) = One1(j) + 1
Next j
Next i
For k = 1 To 30 Step 1
Sheet1.Cells(k + 1, 2) = Three3(k)
Sheet1.Cells(k + 1, 3) = Two2(k)
Sheet1.Cells(k + 1, 4) = One1(k)
Next k
End Sub

*The x array represents individual balls being picked by the var variable. The results are plugged into a standard Excel spreadsheet, and they represent the number of times, out of 200,000 potential drafts, each different category of team got a certain pick. After that it was just simple Excel mathematical manipulation. You can get more precise data by increasing the 200,000 number in the first For loop to about 2,000,000. I tried it but my machine couldn't run the program. If anyone wants me to explain it a little more, I'll be happy to try.

5. ### al3xRegistered User

Joined:
Jul 12, 2005
Messages:
239
0
Trophy Points:
74
Occupation:
student
Location:
Bucharest,Romania
could you translate it into C/C++? pls

6. ### ginner classicRegistered User

Joined:
Mar 4, 2002
Messages:
9,484
1
Trophy Points:
0
Occupation:
Management Consultant
Location:
Kitsilano
Do you happen to know where I can get a program to do a probability run on a casino card game? Wanting to do an analysis of Let it Ride and Carib Stud. let me know if you've ever seen anything.

7. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
Never worked with C++, but I imagine it's pretty easy. It's just initializing some variables and doing some For loops and If Then Else stuff.

8. ### hossy316Registered User

Joined:
Oct 25, 2003
Messages:
2,245
0
Trophy Points:
0
Occupation:
Location:
Kensington, PEI
HaHa, the Million \$ question!!

9. ### al3xRegistered User

Joined:
Jul 12, 2005
Messages:
239
0
Trophy Points:
74
Occupation:
student
Location:
Bucharest,Romania
yeah i understand most of the things you're doin' there but i'm 2 lazy to read all of it and i only have a c++ compiler .. anyway, great job!

10. ### ginner classicRegistered User

Joined:
Mar 4, 2002
Messages:
9,484
1
Trophy Points:
0
Occupation:
Management Consultant
Location:
Kitsilano
Just to lazy to sit down and figure it out myself.

11. ### jeffbrownRegistered User

Joined:
Feb 18, 2003
Messages:
452
0
Trophy Points:
0
Location:
Toronto
You're studying for the Bar exam...as in law? Wow, and you can program too.

Good luck!!

12. ### GoldyRegistered User

Joined:
Feb 28, 2002
Messages:
189
0
Trophy Points:
0
Location:
Minneapolis
Dang - you beat me to it. I was going to wait until after work to do this!

13. ### hossy316Registered User

Joined:
Oct 25, 2003
Messages:
2,245
0
Trophy Points:
0
Occupation:
Location:
Kensington, PEI
You must be relieved, seems like a lot of work!

14. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
I was a chemical engineer before I went to law school. I did a lot of computer simulations and basic Visual Basic programming as part of my Master's work and later my job. It's been a few years and I had to go back and relearn the basics of Basic programming. The algorithm isn't that hard though. Once I got rid of all the syntax errors, I only had to make a few minor to the actual algorithm to get it to work right.

All told, I spent about 2 hours on it.

Joined:
Aug 13, 2002
Messages:
4,929
181
Trophy Points:
156
Gender:
Male
Location:
Toronto
Wow HighlyRegardedRookie that is impressive! Thanks!

Here are a few more probabilities I got from the numbers in your simulation:

a) A 3-ball team has about a 29% chance of getting a top-5 pick
b) A 2-ball team has about a 21% chance of getting a top-5 pick
c) A 1-ball team has about a 11% chance of getting a top-5 pick

d) A 3-ball team has about a 55% chance of getting a top-10 pick
e) A 2-ball team has about a 41% chance of getting a top-10 pick
f) A 1-ball team has about a 23% chance of getting a top-10 pick

I was gonna calculate these probabilities using stochastic processes (I'm a Mathematics major), but it's much easier to use your simulation, and I'm lazy and dumb

Last edited: Jul 14, 2005
16. ### King'sPawnEnjoy the chaos

Joined:
Jul 1, 2003
Messages:
11,567
978
Trophy Points:
214
Seems like there's a flaw. Isn't the percentage of picking based upon the number of balls that are removed?

For example, let's say your team is Detroit. You have 1 ball out of 48. That's 2.08% chance of getting the #1 pick. Now let's say Toronto gets the #1 pick. That means Detroit would have a 2.12% (1/47) chance of getting the second overall pick. However, if Buffalo gets the 1st overall pick, Detroit would have a 2.22% (1/45).

Now let's say Toronto and Philadelphia get #1 and #2. That would mean the Red Wings have a 2.17% (1/46) chance of getting the third overall pick. However, if Buffalo and New York get the top 2 picks, the Red Wings would have a 2.38% (1/42) chance of getting third overall.

If all three ball teams get picked first, that would give the Red Wings a 2.78% (1/36) chance of picking 5th, as opposed to a 2.32% chance of picking 5th if four one-ball teams go first.

It's good to illustrate a point, but it's not exact.

17. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
I took that into account in my program.

The x array represents all of the balls in the balls in the hopper (ball 49 is just a place holder). They're initialized to different variables to represent different "kinds" of draft possibilities.

Teams with 3 draft balls are initialized to have their X values set to 5, 3, and 4. Five means that when that ball is picked, you have to register that one and the next two as having been picked. Three means that you set that one, the previous one, and the next one to register it having been picked. Four means you reset that one and the previous two. (5 then represents the "first" ball, 3 represents the "second", and 4 represents the "third"). I realize the notation is confusing and if I truly meant for it to be shared with others who would modify it for their own purposes or something like that, I would have gone back and rewritten it to be easier to follow.

To be complete, teams with two balls have their X values initialized to 1 and 2. One means you reset that ball and the next one. Two means you reset that ball and the previous one. One-ball teams have theirs set to 0, which means to just look at that ball.

I register that a team has been picked by changing all of its X-values to 6.

The variable "var" is the ball that is picked. After picking a ball, I go through and check whether it, or one of its companions, has been picked before. If it has, I just pick a new one.

Last edited: Jul 14, 2005
18. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
Oh, I think I understand your question now. You're pointing out that your percentages of getting a certain pick is dependent on exactly who is picked in front of you. Well, it was actually the primary goal of my simulation to take that into account. That's why I had the program simulate the draft 200,000 times. That way, you start averaging out all the variation that comes from the differences you talk about.

My program does not break it down by those variables. It averages them out. If you want to figure out what happens at pick #2 assuming pick #1 goes to a certain team, it's pretty easy. There are 48 balls. If a 3-ball team gets #1, there are then 45 balls. The remaining 3-ball teams have a 3/45 chance of getting pick #2. The 2-ball teams have a 2/45 chance, and the 1-ball teams have a 1/45 chance. If it's a two-ball team or a one-ball team that gets #1, just add 1 or 2 to the denominators above, and you get the answer.

The program starts from time zero (now) and predicts your team's individual chances of getting whatever pick. Once the first ball is picked, my statistics won't help you anymore.

19. ### MaVRegistered User

Joined:
Jun 23, 2002
Messages:
483
0
Trophy Points:
0
Occupation:
Spin doctor
Those numbers aren't really accurate yet though, or? I mean, shouldn't the three balls holders simply have 3/48 chance for the first pick? That's 6,250 and your number is slightly less. The same with three ball holder for second pick 9/48*3/45 + 20/48*3/46 + 16/48*3/47 is 6,095, again your simulation gives slightly smaller chances. So, maybe it would need to be run even more times to get the numbers right. It's very complicated system anyway.

20. ### MojoJojoRegistered User

Joined:
Jan 31, 2003
Messages:
9,354
0
Trophy Points:
0
Location:
I'm not sure you did this right, though I am a C programmer and can only generally follow what you did. Basically the problem is that you need to account for the number of balls removed from the pool with each draft pick. In a multiball system this is difficult, because the number changes depending on who got what pick before the pick you are calculating, ie, for the second pick you need to add up the probability that first pick was taken by a one, two and three ball team. The third pick you need to add up the probablities that between 2 and 6 balls were removed in the first two picks, etc.

21. ### King'sPawnEnjoy the chaos

Joined:
Jul 1, 2003
Messages:
11,567
978
Trophy Points:
214
Thanks for clarifying, HRR. I misunderstood the premise of your program

So basically you ran the program x amount of times, and you averaged out the results? Meaning in any given simulation, there was probably a time when all of the 1 balls were drafted before anyone else... but there was another time when all of the 1 ball teams were drafted last? Your program averaged it out like that?

If that's what you did, that makes perfect sense. You were aiming more for a general likelihood of each spot as opposed to giving exact numbers.

22. ### NYRangersRegistered User

Joined:
Aug 11, 2004
Messages:
2,850
0
Trophy Points:
0
The 4 "bad" teams have a 25% chance of getting the top pick.
The 10 "mediocre" teams have a 41.6% chance of getting the top pick.
The 16 "good" teams have a 33.3% chance of getting the top pick.

Crosby is probably going to a somewhat good team.

23. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
No, it's not perfect. The problem is that I only had the program run the draft 200,000 times. It's probably accurate to within a factor of 1-2%. It's not designed to get rock-solid numbers. It's designed to converge to the right answer. It will just take an infinite number of runs to get it perfect. I tried it with 1,000,000 drafts, but the computer I was on wouldn't run it. I'd get overflow errors. To get better numbers, you can just open up an Excel Spreadsheet, go to the VB editor and copy my program into it. Change the 200,000 number to 10 million and see if your machine will run it. It will output the absolute number of times a certain 3-ball team got each pick (I followed balls 1, 2, and 3 for this purpose), the number of times a certain 2-ball team got each pick (I followed balls 13 and 14 for this), and the number of times a certain 1-ball team got each pick (ball 30 I think). Just divide each result by 10,000,000 and multiply by 100 to get percentages. The results will be more accurate than what I got.

24. ### Potted PlantRegistered User

Joined:
May 30, 2003
Messages:
858
0
Trophy Points:
0
Location:
Tuscaloosa, AL
It is done. What I did accounts for that. I assigned all balls to their teams. When one team's ball was picked, I registered all their other balls as picked as well. The mechanics of the program simulate it like this:

Starting with pick #1
1. Pick a ball
2. Check to see that the ball hasn't been picked already.
3. If it hasn't, register that ball as picked.
4. Register each of the team's other balls as picked as well.
5. Put the ball back in the bin
6. Check to see if this is one of the three teams I'm following.
7. If so, register where that team is picking in the order.
8. Go to the next pick and start again.

The same ball could easily be picked twice, but those are just discarded. The pick is also discarded and tried again if another of the same team's balls is picked.

It would be very hard to figure out with mathematical certainty what the chances are. It's easier this way, running a mock draft a couple hundred thousand times and just counting up the results.

25. ### MojoJojoRegistered User

Joined:
Jan 31, 2003
Messages:
9,354
0
Trophy Points:
0
Location: