Re:South Africa's lottery probed as 5, 6, 7, 8, 9 and 10 drawn
by ALittleLight on Wednesday December 02, 2020 @07:32PM
(#25283761)
Unless I'm doing something wrong here - just typing some javascript into the console gives me...
function rn() {
return parseInt(Math.random() * 100);
}
function drawing(){
let result = [rn(), rn(), rn(), rn(), rn()];
return result.sort();
};
function sequential(arr){
for(let i = 0; i < arr.length-1; i++){
if(arr[i] + 1 != arr[i+1]){
return false
}
}
return true
}
let counter = 0;
for (let i = 0; i < 10000000; i ++){
if (sequential(drawing())){
counter ++;
}
};
console.log(counter);
16
Mathematically, it seems like you'd need to draw one of five numbers from the range, then one of four numbers, then one of three... so the likelihood would be 5/100 * 4/100 * 3/100 * 2/100 * 1/100 = 0.000000012. Although those odds don't seem to line up with the javascript I posted.
Edit: What I did was take all the possible combinations of 5 balls (5!) by the number of different sets that could be drawn (50-5, based on lowest number), over the total possible draws (50!). I think perhaps what that does it not account for overlap between sets (1-5 and 2-6), inflating the number somewhat, which is why it's a bit more than twice the probability than you got for any possible sequence of 5.