Hi Icewynd,
I have put this code together that gives
ALL the distributions, the total number of combinations for each distribution, the percentage and the expected to be drawn 1 in "n" draws.
L = LOW ( Numbers - 0,1,2 )
M = MIDDLE ( Numbers - 3,4,5,6 )
H = HIGH ( Numbers - 7,8,9 )
Option Explicit
Option Base 1
Sub List_Permutations_Pick_3_PAB()
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim nMinA As Long
Dim nMaxF As Long
Dim i As Integer
Dim n As Long
Dim Dist As Double
Dim nDist(27) As Double
Dim TotalComb As Long
With Application
.ScreenUpdating = False: .Calculation = xlCalculationManual: .DisplayAlerts = False
End With
nMinA = 0
nMaxF = 9
TotalComb = 1000
For i = 1 To 9
nDist(i) = 0
Next i
With Sheets("Sheet1").Select
Cells.EntireColumn.Delete
Range("A1").Select
n = 0
For A = nMinA To nMaxF
For B = nMinA To nMaxF
For C = nMinA To nMaxF
If A <= 2 And B <= 2 And C <= 2 Then nDist(1) = nDist(1) + 1
If A <= 2 And B <= 2 And C >= 3 And C <= 6 Then nDist(2) = nDist(2) + 1
If A <= 2 And B <= 2 And C >= 7 Then nDist(3) = nDist(3) + 1
If A <= 2 And B >= 3 And B <= 6 And C <= 2 Then nDist(4) = nDist(4) + 1
If A <= 2 And B >= 3 And B <= 6 And C >= 3 And C <= 6 Then nDist(5) = nDist(5) + 1
If A <= 2 And B >= 3 And B <= 6 And C >= 7 Then nDist(6) = nDist(6) + 1
If A <= 2 And B >= 7 And C <= 2 Then nDist(7) = nDist(7) + 1
If A <= 2 And B >= 7 And C >= 3 And C <= 6 Then nDist(8) = nDist(8) + 1
If A <= 2 And B >= 7 And C >= 7 Then nDist(9) = nDist(9) + 1
If A >= 3 And A <= 6 And B <= 2 And C <= 2 Then nDist(10) = nDist(10) + 1
If A >= 3 And A <= 6 And B <= 2 And C >= 3 And C <= 6 Then nDist(11) = nDist(11) + 1
If A >= 3 And A <= 6 And B <= 2 And C >= 7 Then nDist(12) = nDist(12) + 1
If A >= 3 And A <= 6 And B >= 3 And B <= 6 And C <= 2 Then nDist(13) = nDist(13) + 1
If A >= 3 And A <= 6 And B >= 3 And B <= 6 And C >= 3 And C <= 6 Then nDist(14) = nDist(14) + 1
If A >= 3 And A <= 6 And B >= 3 And B <= 6 And C >= 7 Then nDist(15) = nDist(15) + 1
If A >= 3 And A <= 6 And B >= 7 And C <= 2 Then nDist(16) = nDist(16) + 1
If A >= 3 And A <= 6 And B >= 7 And C >= 3 And C <= 6 Then nDist(17) = nDist(17) + 1
If A >= 3 And A <= 6 And B >= 7 And C >= 7 Then nDist(18) = nDist(18) + 1
If A >= 7 And B <= 2 And C <= 2 Then nDist(19) = nDist(19) + 1
If A >= 7 And B <= 2 And C >= 3 And C <= 6 Then nDist(20) = nDist(20) + 1
If A >= 7 And B <= 2 And C >= 7 Then nDist(21) = nDist(21) + 1
If A >= 7 And B >= 3 And B <= 6 And C <= 2 Then nDist(22) = nDist(22) + 1
If A >= 7 And B >= 3 And B <= 6 And C >= 3 And C <= 6 Then nDist(23) = nDist(23) + 1
If A >= 7 And B >= 3 And B <= 6 And C >= 7 Then nDist(24) = nDist(24) + 1
If A >= 7 And B >= 7 And C <= 2 Then nDist(25) = nDist(25) + 1
If A >= 7 And B >= 7 And C >= 3 And C <= 6 Then nDist(26) = nDist(26) + 1
If A >= 7 And B >= 7 And C >= 7 Then nDist(27) = nDist(27) + 1
Next C
Next B
Next A
n = n + 1
Range("A1").Value = "Dist"
Range("A2").Value = "LLL"
Range("A3").Value = "LLM"
Range("A4").Value = "LLH"
Range("A5").Value = "LML"
Range("A6").Value = "LMM"
Range("A7").Value = "LMH"
Range("A8").Value = "LHL"
Range("A9").Value = "LHM"
Range("A10").Value = "LHH"
Range("A11").Value = "MLL"
Range("A12").Value = "MLM"
Range("A13").Value = "MLH"
Range("A14").Value = "MML"
Range("A15").Value = "MMM"
Range("A16").Value = "MMH"
Range("A17").Value = "MHL"
Range("A18").Value = "MHM"
Range("A19").Value = "MHH"
Range("A20").Value = "HLL"
Range("A21").Value = "HLM"
Range("A22").Value = "HLH"
Range("A23").Value = "HML"
Range("A24").Value = "HMM"
Range("A25").Value = "HMH"
Range("A26").Value = "HHL"
Range("A27").Value = "HHM"
Range("A28").Value = "HHH"
Range("B1").Value = "Comb"
Range("C1").Value = "Percent"
Range("D1").Value = "Expected 1 in"
For i = 1 To 27
With ActiveCell
.Offset(i, 1).Value = nDist(i)
.Offset(i, 2).Value = 100 / TotalComb * nDist(i)
.Offset(i, 3).Value = TotalComb / nDist(i)
.Offset(i, 4).Value = "Draws"
.Offset(i + 1, 1).FormulaR1C1 = "=Sum(R2C2:R[-1]C)"
.Offset(i + 1, 2).FormulaR1C1 = "=Sum(R2C3:R[-1]C)"
.Offset(i, 1).NumberFormat = "#,##0"
.Offset(i, 2).NumberFormat = "##0.00"
.Offset(i, 3).NumberFormat = "##0.0000"
End With
Next i
End With
Cells.EntireColumn.AutoFit: Cells.EntireColumn.HorizontalAlignment = xlRight
With Application
.DisplayAlerts = True: .Calculation = xlCalculationAutomatic: .ScreenUpdating = True
End With
End Sub
Let me know what you think!
Regards,
PAB
-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-∏-
12:45, restate my assumptions.
Mathematics is the language of nature.
Everything around us can be represented and understood through numbers.
If you graph the numbers of any system, patterns emerge. Therefore, there are patterns everywhere in nature.