lgojer1234's Blog

Most People Don't Believe that Logically the Lottery Has a Pattern

I did not actually conduct a public opinion poll to measure the responses on this, but from my own experience,

if you were to sample, (say 100 people) most likely very few of them would believe in the idea that the lottery

has some type of provable pattern to it.

Entry #4

The Following is Like an Argument in the Study of Philosophy (For Those Who Might Be Interested)

If it's the case that some people out there in the world believe that it's really possible to predict the lottery with some limited degree of accuracy, then the question arises: could someone with a big enough computer, (like say a mainframe computer) be able to forecast the entire contents of the next day's newspaper (for example like the Dallas Morning News or some other big city newspaper)?

 

The question being raised is: does the second follow in any way as a mathematical exercise or principle from the first?

Entry #3

Lottery Program for Texas Lottery Based on Most Frequent Numbers of the Past 20 Tickets

//
// Lotto6f.cs - program to forecast the lottery
//
using System;
using System.IO;

public class lotto6f
{
public const int max1 = 10000; // max data size
public const int nbits = 42; // number of bits
public const int isiz = 10; // number of reps
public int nnums = 6; // number of numbers
public int[,] data = new int[max1,11]; // data
public int[,] pred = new int[max1,11]; // predictions
public int[,] bitdata = new int[max1,42]; // bit rep. of dta
public double[] scores = new double[8]; // scores of lotto
public double[] scounts = new double[8]; // total number lto
public double[] scoresp = new double[8]; // total score
public int[,] fcastbin = new int[max1,42]; // forecasts
public int[] fcastbin2 = new int[42]; // forecast at end
public int[,] fcastdecimal = new int[max1,11]; // dec. forecasts
public int[] guesses = new int[11]; // guesses
public int[] actual = new int[11]; // actual lotto #s
public int count = 0; // # of tickets
public int[,] factors = new int[5,80]; // discriminant factors
public double[,] table1 = new double[42,2]; // table 1
public double[,] table2 = new double[42,4]; // table 2
public double[,] table3 = new double[42,8]; // table 3
public double qq1 = 0; // intermediate var
public double qq2 = 0; // intermediate var
public double qq3 = 0; // intermediate var
public int predq = 0; // intermediate var
public int kkk = 0; // special supress code
public int[,,] big60 = new int[max1,isiz,7]; // tabulation of final numbers
public int[] max6 = new int[6]; // tabulation of final numbers
public int[] numright2 = new int[7]; // tabulation of final numbers
public int[] datak = new int[7]; // tabulation of final numbers

//
// ProcessLine - to process one line of input of data
//
public void processline(string line1, int count)
{
Console.WriteLine(line1);
string[] strs = line1.Split(',');
int i1 = 0;
for (i1 = 0; i1 < 11; i1++)
{
try
{
data[count,i1] = int.Parse(strs[i1]);
}
catch
{
data[count,i1] = 0;
}
//Console.Write(data[count,i1]+",");
}
//Console.WriteLine();
}

//
// Loadbindata - to load the binary bits from the input file
//
public void loadbindata()
{
int i1 = 0;
int i2 = 0;
int i3 = 0;
int pos = 0;
int k = 0;
int dig = 0;
for (i1 = 0; i1 < count; i1++)
{
for (i2 = 0; i2 < 7; i2++)
{
k = data[i1,i2+4];
for (i3 = 5; i3 >= 0; i3--)
{
pos = i2*6 + i3;
dig = k % 2;
bitdata[i1,pos] = dig;
k = (int)k/2;
//Console.Write(k+" ");
}
//Console.WriteLine();
}
//Console.WriteLine();
}
for (i1 = 0; i1 < count; i1++)
{
//Console.Write((i1+1)+": ");
for (i2 = 0; i2 < 42; i2++)
{
//Console.Write(bitdata[i1,i2]+" ");
}
//Console.WriteLine();
}
}

//
// Loaddata - to load the input file
//
public void loaddata()
{
StreamReader sr = new StreamReader("data1.csv");
bool exitflag = false;
string line1 = "";
while (!exitflag)
{
try
{
line1 = sr.ReadLine();
if (line1[0] != ' ')
{
processline(line1,count);
count = count + 1;
}
else
{
exitflag = true;
}
}
catch
{
exitflag = true;
}
}
sr.Close();
loadbindata();
Console.WriteLine("# of Lines: "+count);
}

public void forecastlotto4()
{
int i1 = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
int kk = 0;
int setup1 = 10;
int[] hist = new int[61];
int[] histn = new int[61];
int num = 0;
int tmp = 0;
Random rand = new Random();
for (i1 = setup1; i1 < (count); i1++)
{
Console.WriteLine("Ticket: "+i1);
Console.Write("Original: ");

for (i2 = 0; i2 < nnums+1; i2++)
{
num = 0;
for (i4 = 0; i4 < 6; i4++)
{
num = num*2 + bitdata[i1,i2*6 + i4];
}


Console.Write(num+",");

}

Console.WriteLine();
Console.Write("Prediction: ");

for (i3 = 0; i3 < 61; i3++)
{
hist[i3] = 0;
histn[i3] = i3;
}
for (i2 = i1 - setup1; i2 < i1; i2++)
{



for (i4 = 0; i4 < 6; i4++)
{
num = 0;
for (i3 = 0; i3 < 6; i3++)
{
num = num*2 + bitdata[i2,i4*6 + i3];
}

if ((num <= 60) && (num > 0))
{
hist[num] = hist[num] + 1;
}

}


for (i3 = 0; i3 < 61; i3++)
{
for (i4 = (i3 + 1); i4 < 61; i4++)
{
if (hist[i3] > hist[i4])
{
tmp = hist[i4];
hist[i4] = hist[i3];
hist[i3] = tmp;
tmp = histn[i4];
histn[i4] = histn[i3];
histn[i3] = tmp;
}
}
}
}

kk = 0;
for (i3 = 0; i3 < 61; i3++)
{
if ((histn[i3] > 0) && (kk < 6))
{
kk = kk + 1;
pred[i1+1,kk-1] = histn[i3];
Console.Write(pred[i1+1,kk-1]+",");
}
}
pred[i1+1,6] = rand.Next(1,6);
pred[i1+1,6] = 3;
Console.WriteLine(pred[i1+1,6]);






}


}

 


public void printresults2()
{
int i1 = 0;
int i2 = 0;
int i3 = 0;
int k = 0;
int found = 0;
//string strq = "";
//string strq1 = "";
try
{
for (i1 = 0; i1 < count; i1++)
{
k = 0;
Console.WriteLine("Ticket: "+i1);
Console.Write("Original: ");
for (i2 = 0; i2 < 7; i2++)
{
Console.Write(data[i1,i2+4]+",");
}
Console.WriteLine();
Console.Write("Forecast: ");
for (i2 = 0; i2 < 6; i2++)
{
Console.Write(pred[i1,i2]+",");
if (i1 < count)
{
found = 0;
for (i3 = 0; i3 < 6; i3++)
{
if (found == 0)
{
if (pred[i1,i2] == data[i1,i3+4])
{
k = k + 1;
found = 1;
}
}
}
}

}
Console.Write(pred[i1,6]+",");
if (pred[i1,6] == data[i1,10])
{
k = k + 1;
}
Console.WriteLine(" # Right: "+k);
scores[k] = scores[k] + 1;
//strq1 = Console.ReadLine();

}
}
catch
{
}


try
{
for (i1 = 0; i1 < 8; i1++)
{
scoresp[i1] = 100*scores[i1]/count;
Console.WriteLine("Score["+i1+"] = "+scoresp[i1]+" %");
}
//strq = Console.ReadLine();
}
catch
{
}
}


public void tabulate4b(int ii)
{
int i1 = 0;
int i2 = 0;
int i3 = 0;
int n = 0;
int tmp = 0;
int[] hist = new int[61];
int[] hist2 = new int[61];
//Console.WriteLine("Ticket: "+ii);
for (i3 = 0; i3 < 6; i3++)
{
//Console.Write(data[ii,i3+4]+",");
}
//Console.WriteLine();

for (i1 = 0; i1 < 61; i1++)
{
hist[i1] = 0;
hist2[i1] = i1;
}

for (i3 = 0; i3 < 6; i3++)
{
for (i2 = 0; i2 < isiz; i2++)
{
n = big60[ii,i2,i3];
hist[n] = hist[n] + 1;
}
//Console.Write(n+",");
}

for (i1 = 0; i1 < 61; i1++)
{
for (i2 = (i1 + 1); i2 < 61; i2++)
{
if (hist[i1] > hist[i2])
{
tmp = hist[i1];
hist[i1] = hist[i2];
hist[i2] = tmp;
tmp = hist2[i1];
hist2[i1] = hist2[i2];
hist2[i2] = tmp;
}
}
}

//Console.WriteLine();
//for (i1 = 0; i1 < 61; i1++)
//{
// Console.Write(hist2[i1]+",");
//}
//Console.WriteLine();
for (i1 = 0; i1 < 6; i1++)
{
datak[i1] = hist2[i1];
}

for (i1 = 0; i1 < 61; i1++)
{
hist[i1] = 0;
hist2[i1] = i1;
}

for (i3 = 6; i3 < 7; i3++)
{


for (i2 = 0; i2 < isiz; i2++)
{
n = big60[ii,i2,i3];
hist[n] = hist[n] + 1;
//Console.Write(n+",");
}

}
//Console.WriteLine();
for (i1 = 0; i1 < 61; i1++)
{
for (i2 = (i1 + 1); i2 < 61; i2++)
{
if (hist[i1] > hist[i2])
{
tmp = hist[i1];
hist[i1] = hist[i2];
hist[i2] = tmp;
tmp = hist2[i1];
hist2[i1] = hist2[i2];
hist2[i2] = tmp;
}
}
}

for (i1 = 6; i1 < 7; i1++)
{
datak[i1] = hist2[i1];
}
//Console.WriteLine("Datak:");
for (i1 = 0; i1 < 7; i1++)
{
//Console.Write(datak[i1]+",");
}
//Console.WriteLine();
}

public void bigsystem()
{

forecastlotto4();




}


public static void Main()
{
lotto6f l = new lotto6f();
bool exitflag = false;
int k = 0;
while (!exitflag)
{
Console.WriteLine("");
Console.WriteLine("Lotto6f.cs - Lottery Forecaster - (c) 2020 Leonard Gojer");
Console.WriteLine("1 - Load Data");
Console.WriteLine("2 - Forecast Lotto");
Console.WriteLine("3 - Print Results");
//Console.WriteLine("4 - Big System");
Console.WriteLine("0 - Exit");
Console.Write("> ");
k = int.Parse(Console.ReadLine());
switch (k)
{
case 1 : l.loaddata();
break;
case 2 : l.kkk = 0;
l.bigsystem();
break;
case 3 : l.kkk = 0;
l.printresults2();
break;
case 4 : l.bigsystem();
break;
case 0 : exitflag = true;
break;
}
}
}
}

Entry #2

System for Playing Texas Lottery "All or Nothing" Game

I am posting this C# program that I wrote in my spare time to this website for anybody here who is interested in seeing it. Feel free to use it withoutany copyright restraint. You can take it and use it to write own program and I don't mind or care. Just remember that there is no warranty or guarantee that the system works and that you use it at your own risk.

 

//---------------------------------------------------------------------------------
//
// AON.cs - All or Nothing Forecaster for the Texas Lottery. (c) 2020 LG Soft.
//
// Wheeling system based on the use of a genetic algorithm.
//
//---------------------------------------------------------------------------------
using System;
using System.IO;

//---------------------------------------------------------------------------------
// aon - main class
//---------------------------------------------------------------------------------
public class aon
{
public const int maxlines = 10000; // max lines in data
public const int maxfields = 50; // max fields in data
public const int ntrials = 5000; // number of genetic tr.
public const int nt = 5; // number of tickets g.
public int[,] data = new int[maxlines,maxfields]; // data to test
public int[] ticket = new int[12]; // one ticket
public int[] winningticket = new int[12]; // store of winner
public int[,] winningtickets = new int[nt,12]; // store of winners
public double maxscore = 0; // highest score in test
public double maxscoref = 0; // total score
public int count = 0; // number of lines
public int winnings = 0; // total winnings
public double winperticket = 0; // avg. win per ticket
public double twinperticket = 0; // total win avg. win
public bool debugflag = false; // when true, dumps var.
public bool debugflag2 = true;

public string outfile = "aon-outputfile.csv"; // output file name

//---------------------------------------------------------------------------------
// Console1 - class for writing output to screen and file
//---------------------------------------------------------------------------------
public class Console1
{
//---------------------------------------------------------------------------------
// WriteLine1 - to write to the screen and file
//---------------------------------------------------------------------------------
public static void WriteLine1(string str1)
{
Console.WriteLine(str1);
aon a = new aon();
StreamWriter sw = new StreamWriter(a.outfile,true);
sw.WriteLine(str1);
sw.Close();
}

//---------------------------------------------------------------------------------
// Write1 - to write to the screen and file
//---------------------------------------------------------------------------------
public static void Write1(string str1)
{
Console.Write(str1);
aon a = new aon();
StreamWriter sw2 = new StreamWriter(a.outfile,true);
sw2.Write(str1);
sw2.Close();
}

//---------------------------------------------------------------------------------
// WriteLine1 - to write to the screen and file
//---------------------------------------------------------------------------------
public static void WriteLine1()
{
Console.WriteLine();
aon a = new aon();
StreamWriter sw3 = new StreamWriter(a.outfile,true);
sw3.WriteLine();
sw3.Close();
}


}

//---------------------------------------------------------------------------------
// cleardata - to clear the data variables
//---------------------------------------------------------------------------------
public void cleardata()
{
int i1 = 0;
int i2 = 0;
for (i1 = 0; i1 < maxlines; i1++)
{
for (i2 = 0; i2 < maxfields; i2++)
{
data[i1,i2] = 0;
}
}
}

//---------------------------------------------------------------------------------
// loaddata - to load the data file for testing the theories of the genetic alg.
//---------------------------------------------------------------------------------
public void loaddata()
{
StreamReader sr = new StreamReader("data1.csv");
bool exitflag = false;
int i1 = 0;
string line1 = "";
//---------------------------------------------------------------------------------
// loop through the input file
//---------------------------------------------------------------------------------
while (!exitflag)
{
try
{
line1 = sr.ReadLine();
}
catch
{
exitflag = true;
}
try
{
i1 = line1.Length;
}
catch
{
exitflag = true;
}
if (!exitflag)
{
string[] fields = line1.Split(',');
int[] fieldsn = new int[fields.Length];
//---------------------------------------------------------------------------------
// parse the data into its fields
//---------------------------------------------------------------------------------
for (i1 = 0; i1 < fields.Length; i1++)
{
try
{
fieldsn[i1] = int.Parse(fields[i1]);
if (debugflag)
{
Console1.Write1(fields[i1]+",");
}
}
catch
{
}
}
if (debugflag)
{
Console1.WriteLine1();
}
for (i1 = 0; i1 < 12; i1++)
{
data[count,i1] = fieldsn[i1+3];
}
count = count + 1;

}
}
sr.Close();
}

//---------------------------------------------------------------------------------
// geneticticket - to generate genetic ticket trials.
//---------------------------------------------------------------------------------
public void geneticticket()
{
int i1 = 0;
int i2 = 0;
bool exitflag = false;
bool sameflag = false;
int n = 0;
Random rand = new Random();
//---------------------------------------------------------------------------------
// generate 12 random numbers that are seleced without repetition
//---------------------------------------------------------------------------------
for (i1 = 0; i1 < 12; i1++)
{
exitflag = false;
while (!exitflag)
{
n = rand.Next(1,25);
sameflag = false;
for (i2 = 0; i2 < i1; i2++)
{
if (ticket[i2] == n)
{
sameflag = true;
}
}
if (sameflag == false)
{
exitflag = true;
}

}
ticket[i1] = n;
}
}

//---------------------------------------------------------------------------------
// match - returns true if two tickets are matches - with a score for partials.
//---------------------------------------------------------------------------------
public bool match(int[] ticket, int i1, ref int w2)
{
bool tmp = false;
int kount = 0;
int i2 = 0;
int i3 = 0;
//---------------------------------------------------------------------------------
// check and see how many numbers match
//---------------------------------------------------------------------------------
for (i2 = 0; i2 < 12; i2++)
{
for (i3 = 0; i3 < 12; i3++)
{
if (data[i1,i3] == ticket[i2])
{
kount = kount + 1;
}
}
}
if ((kount < 5) || (kount > 7))
{
tmp = true;
}
//---------------------------------------------------------------------------------
// assign the winnings based on the rules of the Texas Lottery ALL OR NOTHING game
//---------------------------------------------------------------------------------
if ((kount == 4) || (kount == 8)) { w2 = 2; }
if ((kount == 3) || (kount == 9)) { w2 = 10; }
if ((kount == 2) || (kount == 10)) { w2 = 50; }
if ((kount == 1) || (kount == 11)) { w2 = 500; }
if ((kount == 0) || (kount == 12)) { w2 = 250000; }
return tmp;
}

//---------------------------------------------------------------------------------
// scoregenetic - to score the time series generated with forecasts.
//---------------------------------------------------------------------------------
public void scoregenetic(ref double score, ref int w)
{
int i1 = 0;
int w2 = 0;
w = 0;
//---------------------------------------------------------------------------------
// for each trial, check and see how many numbers match
//---------------------------------------------------------------------------------
for (i1 = 0; i1 < count; i1++)
{
if (match(ticket,i1, ref w2))
{
score = score + 1;
w = w + w2;
}
}
score = score/(count + 0.00001);
if (debugflag)
{
Console1.WriteLine1("Score: "+100*score+" %");
Console1.WriteLine1("Winnings: $"+w);
}
}

//---------------------------------------------------------------------------------
// saveticket - to save the ticket to the store of winning tickets
//---------------------------------------------------------------------------------
public void saveticket()
{
int i1 = 0;
for (i1 = 0; i1 < 12; i1++)
{
winningticket[i1] = ticket[i1];
}
}

//---------------------------------------------------------------------------------
// forecast - to forecast the lottery (main routine)
//---------------------------------------------------------------------------------
public void forecast()
{
int i1 = 0;
double score = 0;
int i2 = 0;
int w = 0;
//---------------------------------------------------------------------------------
// for each trial, generate a random solution and check it's score
//---------------------------------------------------------------------------------
for (i1 = 0; i1 < ntrials; i1++)
{
geneticticket();
if (debugflag)
{
Console1.WriteLine1("Trying Ticket: #"+(i1+1));
}
for (i2 = 0; i2 < 12; i2++)
{
if (debugflag)
{
Console1.Write1(ticket[i2]+",");
}
}
if (debugflag)
{
Console1.WriteLine1();
}
//---------------------------------------------------------------------------------
// record the trial with the highest score
//---------------------------------------------------------------------------------
scoregenetic(ref score, ref w);
if (w > winnings)
{
maxscore = score;
winnings = w;
winperticket = winnings/(count + 0.00001);
saveticket();
}

}
//---------------------------------------------------------------------------------
// add up the total winnings
//---------------------------------------------------------------------------------
twinperticket = twinperticket + winperticket;
}

//---------------------------------------------------------------------------------
// printresults - to print out the results to the screen and file
//---------------------------------------------------------------------------------
public void printresults()
{
int i1 = 0;
Console1.WriteLine1("Score:");
Console1.WriteLine1(maxscore*100+" %");
Console1.WriteLine1("Max Winnings:");
Console1.WriteLine1("$"+winnings);
Console1.WriteLine1("Winning Ticket:");
for (i1 = 0; i1 < 12; i1++)
{
Console1.Write1(winningticket[i1]+",");

}
Console1.WriteLine1();
Console1.WriteLine1("Winnings Per Ticket");
Console1.WriteLine1("$"+winperticket);
}

//---------------------------------------------------------------------------------
// tabulate - to tabulate the scoring process
//---------------------------------------------------------------------------------
public void tabulate()
{
int i1 = 0;
int i2 = 0;
int i3 = 0;
int w2 = 0;
int w = 0;
int[] ticketq = new int[12];
double score5 = 0;
int mf = 0;
//---------------------------------------------------------------------------------
// for each line, check and see how well it matched
//---------------------------------------------------------------------------------
for (i1 = 0; i1 < count; i1++)
{
mf = 0;
w = 0;
for (i2 = 0; i2 < nt; i2++)
{
for (i3 = 0; i3 < 12; i3++)
{
ticketq[i3] = winningtickets[i2,i3];
}
if (mf >= 0)
{
if (match(ticketq,i1, ref w2))
{
score5 = score5 + 1;
w = w + w2;
mf = mf + 1;
}
}
if (i2 == (nt - 1))
{
Console1.WriteLine1("");
Console1.WriteLine1("Winnings for: "+i1+" = $"+(w-12));
}



}

}
score5 = score5/(count + 0.00001);
if (debugflag)
{
Console1.WriteLine1("Score: "+100*score5+" %");
Console1.WriteLine1("Winnings: $"+w);
}
maxscoref = score5*100;
}

//---------------------------------------------------------------------------------
// Main - main line of program aon.cs
//---------------------------------------------------------------------------------
public static void Main()
{
aon a = new aon();
int n = 0;
a.cleardata();
a.loaddata();
int i1 = 0;
//---------------------------------------------------------------------------------
// Opening display of name of the program
//---------------------------------------------------------------------------------
StreamWriter swq = new StreamWriter(a.outfile);
swq.Close();
a.twinperticket = 0;
Console1.WriteLine1();
Console1.WriteLine1(" A O N");
Console1.WriteLine1(" Genetic Lottery Forecasting System");
Console1.WriteLine1(" for the");
Console1.WriteLine1(" All or Nothing Contest");
Console1.WriteLine1(" of the");
Console1.WriteLine1(" Texas Lottery");
Console1.WriteLine1(" (c) 2020 - LG Soft");
Console1.WriteLine1();
//---------------------------------------------------------------------------------
// Loop through each of the N (50) tickets
//---------------------------------------------------------------------------------
for (n = 0; n < nt; n++)
{
Console1.WriteLine1();
Console1.WriteLine1("Ticket Generation: "+(n+1));
//---------------------------------------------------------------------------------
// initialize variables
//---------------------------------------------------------------------------------
for (i1 = 0; i1 < 12; i1++)
{
a.winningticket[i1] = 0;
}
a.maxscore = 0;
a.winnings = 0;
a.winperticket = 0;
//---------------------------------------------------------------------------------
// forecast for that ticket
//---------------------------------------------------------------------------------
a.forecast();
//---------------------------------------------------------------------------------
// store printout of results and tabulate the amount won overall
//---------------------------------------------------------------------------------
a.printresults();
for (i1 = 0; i1 < 12; i1++)
{
a.winningtickets[n,i1] = a.winningticket[i1];
}
}
a.tabulate();
//---------------------------------------------------------------------------------
// print the final win/loss ratio and final amount won overall
//---------------------------------------------------------------------------------
Console1.WriteLine1();
Console1.WriteLine1("Final Score with Combined Tickets:");
Console1.WriteLine1(a.maxscoref+" %");
Console1.WriteLine1("Final Combined Win Per Ticket:");
Console1.WriteLine1("$"+a.twinperticket);
}
}

Entry #1
Page 1 of 1