フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by