Page 1 of 1
Statistical and math code/functions
Posted: Sun Jan 02, 2005 5:45 am
by Clarkent
Anyone know some code and/or function to implement math systems on lottery and/or number extractions ?
E. g. National lottery that extract 6 numbers ... there are a lot of number combinations ... but if I use some math systems (like linear progression ... etc.) I can reduce combinations ... or if I insert some variable restictions (e. g. not considerer all sequential numbers extractions like for example 1,2,3,4,5,6 ... that very difficult to extract) i can to reduce number of combinations, ecc.
I ask if anyone know some script or function, or class o other tool usefull fo this job. PHP of course ...
Thanks
Posted: Sun Jan 02, 2005 6:26 am
by onion2k
I don't actually understand your question, but I will point out that a number sequence such as 1,2,3,4,5,6 is just as likely to come up in the lottery as any other group of 6 numbers.
Posted: Sun Jan 02, 2005 7:09 am
by feyd
Code: Select all
function pickSome( $howMany, $numbers )
{
$final = $numbers;
$howMany = abs(intval($howMany));
if( !is_array($final)) $final = array();
shuffle($final);
return array_slice($final, 0, $howMany);
}
Of course
Posted: Mon Jan 03, 2005 3:42 pm
by Clarkent
Yes ... 123456 are the same probability of any other combination. But I'm looking for a system that allow to define criterials to reduce combinations number.
For that i'm looking fo a math/statistical implementation (in PHP) that allows to insert (for example) 30 numbers and to calculate all combinations of 6 numbers of these 30 numbers. At the same time I should got a system that allows to insert also restriction criterial (for example: calculate all number combination except the combinations that contain more than 4 sequenzial numbers ... for example 34, 45,46,47,48,49).
The restriction criterials are based on a teorical difficulty to extract weird combinations (for example 1,2,3,4,5,6 or, example above, 34,45,46,47,48,49) ...
My english is very very terrible .... sorry
Thanks
Clarkent
Re: Of course
Posted: Mon Jan 03, 2005 4:18 pm
by timvw
Clarkent wrote:Yes ... 123456 are the same probability of any other combination. But I'm looking for a system that allow to define criterials to reduce combinations number.
For that i'm looking fo a math/statistical implementation (in PHP) that allows to insert (for example) 30 numbers and to calculate all combinations of 6 numbers of these 30 numbers.
With recursion you can write it quite easily yourself. Although i'm not going to do your homework, but i'll give you a sample (in euler)
Code: Select all
function buildcombo(V)
if (cols(V) == 1);
return Vї1];
endif;
Combo = zeros(0, 0);
for i = 1 to cols(V);
nV = Vї1:i-1] | Vїi+1:cols(V)];
SCombo = buildcombo(nV);
for j = 1 to rows(SCombo);
Combo = Combo _ (Vїi] | SComboїj]);
end;
endif;
return Combo;
endfunction
Clarkent wrote:
At the same time I should got a system that allows to insert also restriction criterial (for example: calculate all number combination except the combinations that contain more than 4 sequenzial numbers ... for example 34, 45,46,47,48,49).
The restriction criterials are based on a teorical difficulty to extract weird combinations (for example 1,2,3,4,5,6 or, example above, 34,45,46,47,48,49) ...
So first you build all the possible combinations, and then you test each combination and (eventually) push it to the valid_combinations ...
Thanks
Posted: Tue Jan 04, 2005 4:24 am
by Clarkent
Thank you for your helpfulness ... is correct ? Anyway thank you ...