hypersoniq's Blog

Why followers? And an idea for the next script change

When I look at the many ways in the forums to pick lottery numbers, I try to keep in mind what we have available to us. With the draw history, we have the follower data at hand (except for the next draw, of course). The basic premise... (using pick 3 as an example) if they drew a 6 in position 1 last night, I can look to see what followed a 6 in position 1 all through the history. There results a distribution that is about as uniform as raw draw data, but there is one number that has followed the MOST.

So what we are gathering is the MOST FREQUENT follower of the last number drawn.

Doing this manually takes too much time. Doing this with Excel is a clunky process as well, usually involving filtering and conditional formatting. Using a python script to read from a comma separated value file (csv) can perform the same task in about 1 second.

My other hypothesis is that using different follower scenarios together might add weight to the overall pick. So I use direct followers, aka skip1. Also skip2, skip3, skip7, skip14, skip21 and skip28. Why? Imagine a camera at a stop sign where there was an incident. One camera angle can tell a part of the story, but 7 cameras all at different angles paint a more accurate picture of what happened.

My initial code looks at only the most recent followers in each category, but that is where I probably went wrong... I am reading the last chapter of a long book... 

The next iteration of the script will gather ALL follower data from each skip scenario, roll them into a huge list, and make it's pick by using the statistical MODE (as it does now with partial lists) on ALL of the data, ALL at once!

I realize that all numbers have the possibility of following, and that the MOST of something only appears SOME of the time, but I am at a loss for other ideas at the moment.

Although I enjoy writing scripts in Python, I know I am still a novice coder, so a change of that magnitude will take some time to get right. Time I am willing to invest. This behemoth of a script is already 2,200 lines long, and that is with following software engineering best practices like modularity.

It may not be a breakthrough in cranking out straight hits, but it will be the cheapest "system" to play as it only draws one pick, and I feel that based on my limited knowledge of both lottery systems and coding, and my biases about lottery data (the pick 3 is 3 sequential games of 1 in 10, position A has no influence on positions B or C)  this does represent my Best guess.

After this update, I will start making improvements on the visuals, maybe a GUI interface, and I am already working on parsing the PA lottery RSS feed (since they don't provide an api) to make updating the draw history files easier and faster. I can update ALL draw files and generate picks in about 10 minutes. I might consider adding PACash5, Treasure Hunt, Pick2 and PACash4Life, but only if the RSS feed parser script works out.

Anyone else experimenting with Python or another programming language for the purpose of lottery picks?

Entry #226

Test # 2, The Jackpot Games (PB & MM)

The next round of testing will begin Monday (9/11) with the Power ball and end on Saturday(9/16), also with the power ball.

There are actually 3 games involved, the Mega Millions, The Power ball, and PA's Power Ball Double Play (a separate game with a separate draw history, also a different prize payout... no multiplier and top prize always $10M)

Since you MUST enter a draw into the main PB game, there will be 2 picks for each powerball draw. Adding the multiplier and double draw entry fee, that means both picks are eligible for prizes in both games. For the purpose of this test, results will be separated, so the first line only counts for the main game, and the second only counts for the double draw. Any coincidental payouts won't count.

2 tickets loaded with options for the power ball is a cost of $8

The Mega Millions with the megaplier is a cost of $3

Total System Test Cost = $30 across 3 PB and 2 MM draws. Test duration = 6 days. Pick Method = My Super Seven Python follower script described in detail in earlier blog posts.

The Goal = A hit or combination of hits that exceed the test cost of $30. 

The expectation... it is all coincidental anyway, the realistic expectation is that I donate $30 to "Older Pennsylvanians"

Unlike the last test, this only has to work once!

Entry #225

Follower category weights

The script I wrote generates 2 distinct categories of data.

1.full count of follower data over the entire game history. Presented as a ranked count, most occurrences to least.

2. The most recent lists, which vary based on the last draw (if a 5 came up in that position last, then the next list length will be 5.)

I am wondering if maybe there is a way to weight the recent list numbers with the full list count results.

The data for the short lists is combined to get the pick. I could also print the individual scenario picks (skip 1, skip 2, skip 3, skip 7, skip 14, skip 21 and skip 28), but to what end?

I have also thought about adding 2 new perspectives... skip 182 and skip 364. Not sure if they will help.

It all comes down to the pick, I am sure I could do more, but what?

Entry #224

Half way through the 4 day test.

The first 2 days of testing on the PA pick 3/4/5 (mid and eve) and the Match 6 are done.

Cost to date: $20

Wins to date: $2 on Match 6 on the first day.

Net result: -$18


1. The picks have numbers in position and out of position (so the box has been close a few times, a worthwhile add)

2.  Even with manual updates to all 7 history files, the picks can be obtained in about 15 minutes, which makes this one of the fastest workflows of any system I have developed.

3. The pick 3 is the most wildly variant, sometimes the pick has no matches.

4. The pick 5 has consistently had 2 or 3 numbers match, though not all in position.


So, midway through it is still, like all other systems, coincidental. Post test, cycling the p3 p4 and p5 would be even cheaper to run.

Because it is coincidental, there is no need to go through the hassle of rushing the back test script, the value there is in just making it work. Still going to create it, I just feel the results will not be as important as I thought it might.

Onward to day 3...

Entry #223

Why does Mr. "One line" play 2 lines on PowerBall?

The main focus of every system that I have developed (and subsequently abandoned) was always one single bet.

For pick 3/4/5 just one play each

For Mega Millions and Match 6, just one line

Power ball in PA presents a unique case. My pick for the PB is based only on the dataset of results for the current matrix. PA also offers Double Play. I pick that line based solely on the double draw results dataset. BUT... you can't just enter the double draw, you need to enter the main draw and pay an extra $1 to get in the double draw.

Therefore power ball is my only exception to the "one line per game" goal I have set. Though technically it is one line per game, the requirement is to play for both games.

Entry #222

The next steps for my Python follower system script...

Since the core logic is tested and functioning,time to consider the next steps...

1. Create a desktop application around the script. This will be valuable practice for user interface/ user experience (UI/UX). Using the PA lottery ball images instead of text output would be both easier to read (totally a thing for us older folks) and visually appealing.

2. Add an update the draws option. While it would be nice for the PA lottery to have an API, they sadly do not... but they DO have an RSS feed! I will practice parsing this feed, converting the data to a usable form (text to integer for results and text date to date for draw date.) And then having it build an update sequence to append to all of the results history .csv files. Would have allow for updating multiple draws if I miss a day or two.

3. Work in a back test screen.

4. Work in a statistics screen to display the verbose info for each draw, though the main output would be just the picks.

5. Work in a historical function that can show the results of system pick vs actual draw and derive statistics from that info. Maybe an adjustable time frame, such as last week/month/year/custom date range... would basically just let you query the data from the back test.

6. Figure out how to wrap it into an android solution so the entire package can be 100% mobile.

So while waiting for a win, there is still so much to do... free software engineering lab!

Entry #221

Trying this new configuration for PA pick 3 9/2/2023

Here is the output... (5-8-3 mid day and 8-5-0 evening). note how the list lengths equal the last draw result... Auto ranging! Now let's see if it might work...

Pick 3 Mid Day Followers

The number of followers in the RECENT lists: 5, total followers evaluated: 35
Mode of most recent followers sets combined (The pick!) is >>> 5.0 <<<


The number of followers in the RECENT lists: 2, total followers evaluated: 14
Mode of most recent followers sets combined (The pick!) is >>> 8.0 <<<


The number of followers in the RECENT lists: 3, total followers evaluated: 21
Mode of most recent followers sets combined (The pick!) is >>> 3.0 <<<


Pick 3 Evening Followers

The number of followers in the RECENT lists: 8, total followers evaluated: 56
Mode of most recent followers sets combined (The pick!) is >>> 8.0 <<<


The number of followers in the RECENT lists: 9, total followers evaluated: 63
Mode of most recent followers sets combined (The pick!) is >>> 5.0 <<<


The number of followers in the RECENT lists: 4, total followers evaluated: 28
Mode of most recent followers sets combined (The pick!) is >>> 0.0 <<<



Entry #220

What did I overlook?

The current follower system has a setting for list length that can be unique to each game, but the same across positions. That is what I overlooked. The ability to set the list length for each position... I will remedy that!

Each position in pick 3 (and beyond) has it's own history, and might give better results if it had it's own list length. I will set up the unique variables to pass these in during the function call as parameters. I will determine in the short term here which lengths to use by solving tonight's draw BEFORE updating the csv draw files. Though it has the potential for over fitting, the limits will be to choose the lowest list length that contains the winning number... even if it was not the one picked. May take longer than one night to implement, but I think it is the next logical step.

I have already started the script that will perform the back test, begun by suppressing the verbose output and limiting it to list length (which will also be suppressed later) and the pick.

Going to try starting at between 2 and 3 years of seed data, for example pick 3 from the start to dec. 31st 1979 and begin that back test from January 1st, 1980, as the past draws are far back enough to allow follower data, and that information would have been a priori.

A statistics based system might not be glamorous or as fun as picking 100 numbers for all states, but if it works at an interval to hit enough to be profitable, then it will be worth the time, and for the jackpot games implementation, that only needs to work once.

Entry #219

Trying to fit the jackpot games (MM and PB) into the new program.

While calibrating the dailies (pick 3, 4 & 5) on paper, I ran the mega millions data for 7 different settings. It picked several mega balls, but the most consistent one was 25, the one drawn last night,  white balls could only manage one. This might not be the tool for the white balls, but it does seem useful in narrowing down a good Mega Ball pick. Testing tonight on the power ball.

I played 7 lines of MM last night (total cost $21, with megaplier) and brought in $42.

Letting that $42 roll with similar test on the power ball tonight. The difference being the cost of the test... as I keep separate data for the power ball double play that they pick in PA. The $42 will require an additional $14. Nothing ventured, nothing gained. The results from last night let me pick a setting for MM and for all of the un-played draw games. The one annoying anomaly... again the mid day winner (straight) was among the evening picks... twice in 2 weeks.

After this test to dial in the power ball, I will have all the list lengths set and go back to 1 pick per draw, no guarantee, but I will honestly be able to say it is my best guess.

Working out the most affordable play strategy, then a proper live test can be conducted (with LP predictions to record progress)

Made a copy of the script to start modifying output for the back test. Not going to be easy, but will be worth the knowledge gained in manipulating 2 CSV files in the same script at the same time.

Entry #218

Time to refocus, tweaking the settings...

The ultimate goal is one pick for one game. There are really 3 parameters I can adjust...

1. The number of recent followers in each list

2. The number of lists

3. The skip length of each list

The day for night thing was an observation when the pick for day came out straight for night, but that adds cost and defeats the original purpose of the system.

The list length is the easiest to adjust. Perhaps the next move should be to try several list lengths at once to see which one got closest to the last draw before updating the databases today. That sounds like the plan. I expect that each game may have it's own list length setting.

Also making a copy of the script, suppressing all output but the picks and getting the new script ready to process the back test.

Entry #217


One test for the new script is setting the most recent list length to one... accomplishes an expected behavior and a fall back one...

1. Expected behavior is to return the mode, or most frequent of the 7 individual followers.

2. Fallback behavior... if all 7 are different, choose the first follower (the most recent).

No code changes were required, just passing each function the value of 1 for number of followers. It is looking at

Direct follower

Skip 1 follower

Skip 2 follower

Skip 7 follower

Skip 14 follower

Skip 21 follower

Skip 28 follower

So it always has 7 numbers to work with.

Worth a test on tomorrow's PA pick 3...

Mid day best guess... 289

Eve best guess... 965

Based on recent observations, going to play each pick for day and night.

Entry #216

5 out of 6 on the PA Match six last night, but not on the system generated line

Mixed result... system pick was 0 matches, but the last QP line had 5 of 6, and the 6th winning number was above on qp line 2...

So the system did not work for the win, but I would not have played that ticket if I wasn't testing the system.

Total win was $1,025

The other anomaly last night was on the pick 3, the number that my system gave for the mid day came out straight at night... did not play day for night because of the added cost, but I couldn't help but notice that.

Might be worth keeping an eye on for the rest if the week. Playing each pick for both doubles the play cost to $4/day and shortens the profitability window to a win within 125 draws.

Still planning the back test parameters, possibly limiting the starting pool to 3 years as the other games were not around as long as the pick 3.

It did not escape me that I was 1 number away from 1.6 million last night. But since it was on a QP line, it does not give the system development any real motivational boost. That motivation comes from the challenge of applying unit test best practices to the back test phase.

Entry #215

What I look for in a pick 3 back test

It is all about gaps. The gaps between wins.

What you can tell right away...

A maximum gap (longest stretch between wins) of 501 days or more indicates a system that is not profitable.

The average gap has no value.

The minimum gap is the number of days you can confidently STOP playing. If you don't play every draw, your expense in chasing the next win is reduced! If there is an anomaly like a back to back win, it can most likely be discounted as an outlier. By looking at the gap data, there is a statistics formula to determine outliers.

So the use is...

Max gap determines profitability... is the system worth pursuing?

The min gap determines when to NOT play to save on the play budget.

I am still on the part of my system where I can get picks, but have not finished the back test yet. I may play on occasion to try and get a win, but I won't have this info immediately. 

There are no guarantees, but this idea helps reduce the play expense, thereby maximizing profitability.

Entry #214

Anatomy of a back test using Python

The initial scenario that comes to mind when envisioning a proper backtest for this follower system would be to 

1. Pick a point in history where the test should start. A follower system should have some data to work with. Perhaps the number of draws in the pick 5, around 5k. There are 16k draws on the evening pick 3, so that seems about right.

2. Run the program with only that history, record the pick.

3. Fetch the next result from the full history file.

4. Compare the pick with that result, if a match record the date and number.

5. Re-run the script, repeat until the history file is fully loaded and there are no more draws to add. 

Assuming the cyclic rate hovers around 1 second, there will be 11,000 ish iterations, so run time can be predicted to be around 3 hours.

I should only need to do this for the pick 3 games, then I can say I gave my all in the due diligence department, plus it will be experience in writing unit tests... a real opportunity to use software engineering best practices!

After that, the back test can be used to check settings at 3 hours a shot. Onward!

Entry #213

Live Fire pick 3 test for Pennsylvania

As promised, the output of my Python script for the drawings of the PA Pick 3 (Mid day and evening). I will also post the predictions. There is a great deal of info, but the pocks are easy to see, surrounded by >>> <<<. the picks are as follows (For Tuesday, August 22nd, 2023) ; 

MidDay: 4-8-9

Evening: 0-2-0

====================== RESTART: C:\Python39\superSeven.py ======================
Daily Lottery Follower Frequency Analyzer
Super Seven Edition!
Software by HyperSoniQ
Pick 3 Mid Day Followers
last drawn A =  4 , secondary =  9 , tertiary =  3
Skip Seven =  2 , Skip Fourteen =  6 , Skip Twenty One =  8
Skip Twenty Eight =  2

Primary Followers :  [7.0, 3.0, 4.0, 8.0, 8.0, 3.0, 6.0, 8.0, 0.0]
Secondary Followers :  [3.0, 7.0, 4.0, 4.0, 8.0, 1.0, 8.0, 2.0, 2.0]
Tertiary Followers :  [2.0, 6.0, 7.0, 2.0, 6.0, 4.0, 4.0, 5.0, 0.0]
Skip 7 Followers :  [9.0, 8.0, 4.0, 0.0, 5.0, 6.0, 3.0, 1.0, 9.0]
Skip 14 Followers :  [6.0, 7.0, 4.0, 6.0, 7.0, 7.0, 5.0, 3.0, 1.0]
Skip 21 Followers :  [4.0, 2.0, 5.0, 6.0, 4.0, 7.0, 7.0, 4.0, 9.0]
Skip 28 Followers :  [8.0, 8.0, 7.0, 3.0, 8.0, 0.0, 0.0, 3.0, 4.0]
The number of followers of 4 is 768
The number of 1 skip followers of 9 is 750
The number of 2 skip followers of 3 is 748
The number of 7 skip followers of 2 is 742
The number of 14 skip followers of 6 is 742
The number of 21 skip followers of 8 is 725
The number of 28 skip followers of 2 is 740
The number of followers in the RECENT lists: 9, total followers evaluated: 63
Mode of most recent followers sets combined (The pick!) is >>> 4.0 <<<


last drawn B =  8 , secondary =  1 , tertiary =  8
Skip Seven =  1 , Skip Fourteen =  1 , Skip Twenty One =  8
Skip Twenty Eight =  5

Primary Followers :  [1.0, 8.0, 0.0, 7.0, 7.0, 5.0, 1.0, 0.0, 5.0]
Secondary Followers :  [7.0, 0.0, 8.0, 1.0, 8.0, 3.0, 1.0, 2.0, 8.0]
Tertiary Followers :  [8.0, 0.0, 1.0, 8.0, 3.0, 1.0, 4.0, 9.0, 5.0]
Skip 7 Followers :  [1.0, 6.0, 7.0, 1.0, 0.0, 0.0, 5.0, 8.0, 6.0]
Skip 14 Followers :  [8.0, 1.0, 7.0, 0.0, 8.0, 5.0, 6.0, 8.0, 2.0]
Skip 21 Followers :  [6.0, 8.0, 0.0, 0.0, 0.0, 3.0, 5.0, 2.0, 6.0]
Skip 28 Followers :  [1.0, 6.0, 1.0, 3.0, 8.0, 0.0, 3.0, 5.0, 6.0]
The number of followers of 8 is 746
The number of 1 skip followers of 1 is 760
The number of 2 skip followers of 8 is 745
The number of 7 skip followers of 1 is 759
The number of 14 skip followers of 1 is 758
The number of 21 skip followers of 8 is 741
The number of 28 skip followers of 5 is 726
The number of followers in the RECENT lists: 9, total followers evaluated: 63
Mode of most recent followers sets combined (The pick!) is >>> 8.0 <<<


last drawn C =  2 , secondary =  9 , tertiary =  2
Skip Seven =  8 , Skip Fourteen =  9 , Skip Twenty One =  3
Skip Twenty Eight =  8

Primary Followers :  [9.0, 4.0, 3.0, 1.0, 9.0, 9.0, 9.0, 6.0, 9.0]
Secondary Followers :  [4.0, 3.0, 5.0, 4.0, 6.0, 3.0, 8.0, 8.0, 5.0]
Tertiary Followers :  [2.0, 2.0, 6.0, 3.0, 4.0, 3.0, 0.0, 2.0, 0.0]
Skip 7 Followers :  [2.0, 3.0, 9.0, 0.0, 3.0, 3.0, 9.0, 4.0, 9.0]
Skip 14 Followers :  [0.0, 5.0, 4.0, 1.0, 9.0, 2.0, 3.0, 2.0, 8.0]
Skip 21 Followers :  [9.0, 2.0, 0.0, 9.0, 6.0, 5.0, 9.0, 2.0, 1.0]
Skip 28 Followers :  [4.0, 4.0, 2.0, 0.0, 0.0, 1.0, 3.0, 8.0, 5.0]
The number of followers of 2 is 758
The number of 1 skip followers of 9 is 778
The number of 2 skip followers of 2 is 757
The number of 7 skip followers of 8 is 772
The number of 14 skip followers of 9 is 777
The number of 21 skip followers of 3 is 731
The number of 28 skip followers of 8 is 770
The number of followers in the RECENT lists: 9, total followers evaluated: 63
Mode of most recent followers sets combined (The pick!) is >>> 9.0 <<<


Pick 3 Evening Followers
last drawn A =  0 , secondary =  6 , tertiary =  7
Skip Seven =  9 , Skip Fourteen =  9 , Skip Twenty One =  0
Skip Twenty Eight =  6

Primary Followers :  [8.0, 0.0, 8.0, 1.0, 5.0, 6.0, 3.0, 8.0, 6.0]
Secondary Followers :  [7.0, 9.0, 0.0, 5.0, 3.0, 8.0, 1.0, 4.0, 0.0]
Tertiary Followers :  [0.0, 9.0, 5.0, 5.0, 0.0, 3.0, 5.0, 7.0, 7.0]
Skip 7 Followers :  [9.0, 6.0, 3.0, 6.0, 8.0, 2.0, 6.0, 0.0, 8.0]
Skip 14 Followers :  [6.0, 9.0, 0.0, 7.0, 8.0, 4.0, 4.0, 1.0, 3.0]
Skip 21 Followers :  [0.0, 6.0, 4.0, 5.0, 9.0, 8.0, 5.0, 1.0, 4.0]
Skip 28 Followers :  [0.0, 9.0, 1.0, 9.0, 6.0, 5.0, 4.0, 2.0, 7.0]
The number of followers of 0 is 1693
The number of 1 skip followers of 6 is 1632
The number of 2 skip followers of 7 is 1686
The number of 7 skip followers of 9 is 1550
The number of 14 skip followers of 9 is 1549
The number of 21 skip followers of 0 is 1692
The number of 28 skip followers of 6 is 1628
The number of followers in the RECENT lists: 9, total followers evaluated: 63
Mode of most recent followers sets combined (The pick!) is >>> 0.0 <<<


last drawn B =  5 , secondary =  6 , tertiary =  4
Skip Seven =  4 , Skip Fourteen =  7 , Skip Twenty One =  9
Skip Twenty Eight =  3

Primary Followers :  [2.0, 4.0, 6.0, 0.0, 8.0, 1.0, 8.0, 7.0, 7.0]
Secondary Followers :  [2.0, 1.0, 1.0, 8.0, 4.0, 8.0, 5.0, 2.0, 8.0]
Tertiary Followers :  [4.0, 2.0, 6.0, 7.0, 2.0, 7.0, 2.0, 4.0, 0.0]
Skip 7 Followers :  [9.0, 5.0, 0.0, 9.0, 2.0, 9.0, 2.0, 0.0, 5.0]
Skip 14 Followers :  [9.0, 4.0, 5.0, 1.0, 9.0, 4.0, 5.0, 0.0, 8.0]
Skip 21 Followers :  [4.0, 0.0, 0.0, 7.0, 8.0, 2.0, 9.0, 1.0, 3.0]
Skip 28 Followers :  [7.0, 1.0, 6.0, 5.0, 2.0, 0.0, 9.0, 2.0, 1.0]
The number of followers of 5 is 1661
The number of 1 skip followers of 6 is 1638
The number of 2 skip followers of 4 is 1614
The number of 7 skip followers of 4 is 1612
The number of 14 skip followers of 7 is 1641
The number of 21 skip followers of 9 is 1613
The number of 28 skip followers of 3 is 1594
The number of followers in the RECENT lists: 9, total followers evaluated: 63
Mode of most recent followers sets combined (The pick!) is >>> 2.0 <<<


last drawn C =  2 , secondary =  6 , tertiary =  0
Skip Seven =  6 , Skip Fourteen =  2 , Skip Twenty One =  4
Skip Twenty Eight =  3

Primary Followers :  [0.0, 2.0, 5.0, 4.0, 8.0, 2.0, 7.0, 2.0, 5.0]
Secondary Followers :  [0.0, 6.0, 9.0, 3.0, 6.0, 4.0, 4.0, 5.0, 6.0]
Tertiary Followers :  [6.0, 2.0, 4.0, 4.0, 6.0, 5.0, 5.0, 2.0, 1.0]
Skip 7 Followers :  [0.0, 0.0, 2.0, 8.0, 8.0, 4.0, 0.0, 0.0, 4.0]
Skip 14 Followers :  [2.0, 8.0, 2.0, 4.0, 5.0, 8.0, 2.0, 4.0, 0.0]
Skip 21 Followers :  [0.0, 2.0, 3.0, 8.0, 5.0, 6.0, 0.0, 0.0, 5.0]
Skip 28 Followers :  [2.0, 1.0, 4.0, 0.0, 0.0, 1.0, 0.0, 9.0, 2.0]
The number of followers of 2 is 1653
The number of 1 skip followers of 6 is 1678
The number of 2 skip followers of 0 is 1592
The number of 7 skip followers of 6 is 1676
The number of 14 skip followers of 2 is 1652
The number of 21 skip followers of 4 is 1590
The number of 28 skip followers of 3 is 1611
The number of followers in the RECENT lists: 9, total followers evaluated: 63
Mode of most recent followers sets combined (The pick!) is >>> 0.0 <<<


Program has completed!
Runtime = 0.003891619708802965
Soniq BOOM!

Entry #212