Lottery Code Optimization (Not enough RAM)

3 次查看(过去 30 天)
So I want to create a matrix with all the lottery combinations. 6 numbers between 1 and 49. This gives 13,983,816 possible combinations. From this matrix I will start reducing some combinations such as 6 consecutive numbers, all odd numbers, etc. to theoretically increase my chances. Anyway, I'm stuck at the phase of creating the actual matrix, I only have 16GB of RAM which is not enough. This is my code:
close all; clear all; clc
opt_a=zeros(0,49^6);
opt_b=zeros(0,49^6);
opt_c=zeros(0,49^6);
opt_d=zeros(0,49^6);
opt_e=zeros(0,49^6);
opt_f=zeros(0,49^6);
index=0;
for a=1:49
for b=1:49
for c=1:49
for d=1:49
for e=1:49
for f=1:49
index=index+1;
opt_a(index)=a;
opt_b(index)=b;
opt_c(index)=c;
opt_d(index)=d;
opt_e(index)=e;
opt_f(index)=f;
end
end
end
end
end
end
options=[opt_a' opt_b' opt_c' opt_d' opt_e' opt_f']
Is there anyway to make this code finish running with 16GB of RAM? If not, can I split the code somehow into parts and assemble the parts to create the matrix. Or maybe there already exists such matrix in a txt.file which I can import into Matlab?
Thanks
  3 个评论
John D'Errico
John D'Errico 2015-11-21
编辑:John D'Errico 2015-11-21
How would not having all the odd numbers theoretically increase your chances? (Hint: it does not.) Similarly for consecutive numbers.
Second hint:
help nchoosek
Third hint:
A lottery ticket is a poor way to invest your money in general.
Walter Roberson
Walter Roberson 2015-11-21
Image Analyst: you certainly can use 0 as a argument to zeros.
>> z = zeros(0,49^6)
z =
Empty matrix: 0-by-13841287201

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2015-11-20
"From this matrix I will start reducing some combinations such as 6 consecutive numbers, all odd numbers, etc. to theoretically increase my chances"
To theoretically increase your chances of what? Certainly not your chances of winning: the combination
1 2 3 4 5 6
is exactly the same probability as the combination
14 17 32 38 41 47
unless the random number generator is biased.
I have a suspicion that you also need to read about The Gambler's Fallacy
  3 个评论
Image Analyst
Image Analyst 2015-11-28
Interesting. I wonder if their coin was not fair/evenly weighted. What gave rise to the bias?
Also I wonder why multiple researchers over decades have all disproved hot hand and yet these guys got a contrary result. Supposedly all the others before them didn't know what the heck they were talking about???
And if the streak continues, then the historical mean will start to change and by definition they will eventually start to regress towards the mean.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by