Unique groups of numbers - page 2

 
Like throwing crooked dice. My function is simpler, more efficient and proven correct.
 
What I was looking for was something similar to generating lotto numbers. I got it working thanks with IShuttle function and mathsrand in start()
 

In lotto there are 13,983,816 combinations only with 6 numbers. I am working with over 5 numbers in optimization to find a winning strategy, not sure if Im going the right path here.

When you use 4 different numbers from 1-100 it goes pretty quickly in optimization, I would have thought it would scan a million times. Not sure how it does that.

I put those 4 different numbers combinations in array and then used shuffling with mathsrand to generate unique combinations so that I just have one extern int seed=1; to run in optimization. It looked like it went quicker.

 
bonechair:

In lotto there are 13,983,816 combinations only with 6 numbers. I am working with over 5 numbers in optimization to find a winning strategy, not sure if Im going the right path here. [...]

13,983,816 combinations must be a lottery which picks 6 numbers between 1 and 49. The closest, simplest MT4 equivalent to that is going to be an EA which has 6 extern parameters, and where you tell the optimizer to try every value between 1 and 49 for each parameter. (However, the optimizer doesn't know that the values are meant to be exclusive, and therefore it would try combinations such as 1-1-1-1-1-1 as well as 1-2-3-4-5-6, and 6-5-4-3-2-1 as well as 1-2-3-4-5-6, leading to a truly huge 49^6 = 13,841,287,201 combinations.)
 
WHRoeder:
Like throwing crooked dice. My function is simpler, more efficient and proven correct.


a crooked dice will show a significant difference between the outcome of the different numbers...

only in theorie you have a perfect dice and then also it makes a influence how you throw the dice

we don't mean crooked dices..... your coding is good William and it is fine to see different solutions

i learned

i was giving as example a function to show how you can get a random number from x to y

if you want it in theorie giving each number output same chance of outcome according to me it can be done like this

//+------------------------------------------------------------------+
double MathRandRange(int startrange, int endrange)//x=10 y=20   (10 11 12 13 14 15 16 17 18 19 20)  11 numbers
{


   int kk=MathRand();  //can have output   0....32767
   if(kk>=  32767 - 32767%((endrange-startrange)+1))   //(endrange-startrange)+1)   gives number of range  for 10 - 20  it is 11
       {    //32767 - remainder
       while(kk>=  32767 - 32767%((endrange-startrange)+1))  // avoid first number 0 is counted one time more  >=
           {kk=MathRand();}
       }    

   return(startrange+MathMod(kk,MathAbs(startrange-(endrange+1))));      //+startrange  is giving output lowest value startrange
}

for 11 numbers the remainder will be 0....10

if we put this off of the maximum from mathrand we have numbers with equal chance

 
bonechair:

In lotto there are 13,983,816 combinations only with 6 numbers. I am working with over 5 numbers in optimization to find a winning strategy, not sure if Im going the right path here.

When you use 4 different numbers from 1-100 it goes pretty quickly in optimization, I would have thought it would scan a million times. Not sure how it does that.

I put those 4 different numbers combinations in array and then used shuffling with mathsrand to generate unique combinations so that I just have one extern int seed=1; to run in optimization. It looked like it went quicker.


there are different lotto systems in the world

but if you have to choose 6 numbers in a range from 1 to 49

then you have 49 choices for first number

48 choices for second number to choose

number of possibillities in that case 49 * 48 * 47 * 46 * 45 * 44

it looks to me you're very lucky having the winning combination....

 
deVries:

number of possibillities in that case 49 * 48 * 47 * 46 * 45 * 44

it looks to me you're very lucky having the winning combination....


[ Not strictly relevant, but 49 * 48 * 47 * 46 * 45 * 44 assumes that 6-5-4-3-2-1 is a different draw to 1-2-3-4-5-6. The actual number of different combinations in a 49-ball lottery is the total combinations divided by 6!, which = 13,983,816 as bonechair started off by saying. ]
 
gchrmt4:

[ Not strictly relevant, but 49 * 48 * 47 * 46 * 45 * 44 assumes that 6-5-4-3-2-1 is a different draw to 1-2-3-4-5-6. The actual number of different combinations in a 49-ball lottery is the total combinations divided by 6!, which = 13,983,816 as bonechair started off by saying. ]


you're right you can translate the strategy as if the lotto starts

the first number is a number you have chosen chance is 6/49

for second it makes 5/48 if first was right chosen

so chance of winning with 6 right numbers

(6*5*4*3*2*1)/(49 * 48 * 47 * 46 * 45 * 44)

 

49 numbers taken 6 at a time has 13983816 combinations Combinations and Permutations Calculator

If order is important it has 1.00683475e+10 permutations.

 
WHRoeder:

49 numbers taken 6 at a time has 13983816 combinations Combinations and Permutations Calculator

If order is important it has 1.00683475e+10 permutations.



Yup, that is indeed what we've already been saying. If the order is significant, then the number of permutations is 49! / 43! . If the order is not significant (typical lottery), then the number of combinations is 49! / (43! x 6!)
Reason: