How To Use VBA To Create A Moving Average Of Prime Numbers In Lotto Results

Identifying patterns in lotto outcomes may be tough however one sample that’s constant is the frequency of prime numbers.

Prime numbers ought to make up round 30% of all lotto outcomes and this text introduces the thought of transferring averages and the way they could assist enhance your personal lotto odds.

A transferring common is solely the common over a subset or interval of knowledge. It turns into a robust device when you think about subsequent averages which could point out a transfer away or again to the imply.

Prime Numbers And A Random Data Set

The best approach to check lotto concepts is to create your personal random information set which ought to simulate a collection of lotto outcomes.

You have to create a desk of random outcomes and calculate what number of prime numbers are in every line. Then, we are able to write some VBA code to calculate the common to see if there are any patterns within the numbers.

You ought to have an information desk wanting like this, the place the ultimate column is a depend of what number of primes are in every line.

18 19 26 29 30 33 2
2 9 12 22 35 39 1
6 9 12 19 20 31 2
5 16 20 22 27 29 2
18 20 23 28 31 39 2
3 19 20 27 31 35 3

Now we’re prepared to jot down some VBA code which can calculate the averages.

Lotto Results, VBA Code And Moving Averages

As an instance, in our information set above the end result with a interval of two strains would seem like this.

18 19 26 29 30 33 2
2 9 12 22 35 39 1 1.5
6 9 12 19 20 31 2 1.5
5 16 20 22 27 29 2 2
18 20 23 28 31 39 2 2
3 19 20 27 31 35 Three 2.5

In our VBA code, we’ll use a interval of 10 to get some significant outcomes.

The Excel formulation to create a mean over the primary 10 strains is under, the place “h” is the column which can maintain your outcomes.


To calculate the subsequent 10 interval transferring common you merely increment the row quantity.


In this instance, simply sort the formulation into row “h10” on the proper hand column; then we’ll use VBA code to reiterate by means of the information set.

The code selects the primary cell with the formulation, calculates what number of rows of knowledge there are after which fills in the identical formulation by means of the entire information set.

i = ActiveCell.Offset(0, -1).End(xlDown).Row
Selection.AutoFill Destination:=Range("H10:h" & i)

Development Of The Lotto Prime Numbers Moving Average

When I ran the transferring common module the outcomes got here out as anticipated, with strikes away from the median regularly. Some additional improvement of the module would possibly embrace the next:

  • Creating a chart to allow visible identification of tendencies.
  • Highlighting the strains of knowledge which are above or under the worldwide common.
  • Determining most and minimal variations from the imply.


This article has launched the idea of utilizing VBA code to calculate averages of prime numbers in random information units. The idea can simply be utilized to lotto outcomes and with a little bit creativity different concept and theories may be developed and explored.

Source by A. Lewis Gibson

Leave a Reply

Your email address will not be published. Required fields are marked *