필터 지우기
필터 지우기

Lottery Code Optimization (Not enough RAM)

조회 수: 3 (최근 30일)
john
john 2015년 11월 20일
댓글: Image Analyst 2015년 11월 28일
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
Walter Roberson
Walter Roberson 2015년 11월 28일
See though this article about winning streaks
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