DISCLAMER: This post does not in any way prove or disprove the validity of using neural networks to predict the lottery. It is purely for the purpose of demonstrating certain capabilities available in MATLAB ® . The results and conclusions are my opinion and may or may not constitute applicable techniques of predicting the popular Jamaican Lottery Cash Pot game.

**Background:**

Supreme Ventures Jamaica Limited has a lottery game called Cash Pot (CP) . The game is based on 36 balls being loaded into a chamber and one ball been selected at random from the grouping. The game is ran four (4) times each day seven (7) days per week.

**Anecdotal Heuristics:**

While doing a little tongue and cheek research at my favorite barbershop, I stumbled upon some heuristics that are employed by most patrons who play the (CP) game. One involved writing down the day, time, and winning number for each day’s lottery. After building up a sufficient dataset, they could then query a particular day and time; and with some simple arithmetic tally the most likely number to be played on that day and time. I was informed that this proved to be a very efficient way of telling which number was to be played next. Another popular heuristic involved pre-assigned symbols; these symbols were associated with each of the thirty six (36) numbers. Then based on dreams aka “rakes” numbers would be chosen that matched the symbols seen in the “rake”. These two methods were the favorite amongst the players of Cash Pot.

**Procedure for predicting Cash Pot with MATLAB ANN:**

- Get the dataset from Supreme Ventures Jamaica website. [contains all winning numbers with date and time]
- We will need to do some twiddling with the file in order to get it into a format that MATLAB can use. To do that we need to remove all headings/sub-headings and labels.
- Next remove the DRAW# and MARK columns since we will not be using those in our analysis.
- In column D use the =WEEKDAY() formula to get the day number from the corresponding date: repeat for all rows.
- Use find and replace to replace MORNING with 1, MIDDAY with 2, DRIVETIME with 3 and EVENING with 4. [Save the file]
- Using MATLAB folder explorer, navigate to the file then double click on it to run the import tool.
- Select columns B and D then hit the import button; this should import only columns B and D, rename the imported matrix to cpInputs .
- Select column C and hit the import button; this should import column C only, rename the imported matrix to cpTargets.
- Because MATLAB sees Neural Network(NN) features as rows, transpose the two matrices using
- In the MATLAB command window type nntool.
- Import cpInputs and cpTargets into the NN data manager.
- Hit the new button on the Neural Network Data Manager and change the default name to cpNN.
- Set Input data to cpInputs, Target data to cpTargets.
- Hit the create button to create the NN.
- Let’s go ahead and train this network. On the train tab of the Network: cpNN dialog, select cpInputs for Inputs and cpTargets for Targets; then press the Train Network button to start the network training.
- Results of training.
- After training the network to the desired tolerance’s go back to the Neural Network/Data Manager dialog box and hit the export button, select cpNN from the list then hit the export button.
- Go back to the MATLAB command window and type
- The resulting value will be the NN’s best guess of what will be the winning entry for Cash Pot on a Tuesday at DRIVETIME.

cpInputs = cpInputs’; cpTargets = cpTargets’;

** **

**Note:**

The newly created NN has two inputs, the first been the day of the week on which the [CP] is scheduled to be played and the second input the time of day that the [CP] is scheduled to played. It also has a hidden layer with 10 neurons with associated bias, and an output layer with 1 neuron and its associated bias. The output is a scalar double which represents the predicted winning number.

CpNN([2;3]) % [day;time]

**Conclusions:**

My initial analysis of the results of the NN was not conclusive, maybe the parameters of the NN could be adjusted and the results compared to actual winning numbers. However, even after doing so one may find that the outputs are still random and contain no discernible patterns, which should be the case for a supposedly random game of chance.

So…what numbers playing today?

Purely for research purposes!!

DWL on my !! Don Perry You got jokes

No harm in trying 🙂

hai sir i will give 1 input and 8 outputs,how will get the output,pls mention the command for that?

Hey ganesh, as the post explains the tool box sees NN features as rows; that means the cpInputs vector has two rows which corresponds to two inputs while cpTargets has only one row which corresponds to one output. Your input vector should have one row while your output vector should have 8 rows, hope that clears it up for you.

first i was salute ur response sir, my doubts,i was try in same procedures ,but in last step i had some errors,how i will get desired output,pls clear my doubt

What were the errors that you got on your attempt, a description of you problem may help.

this is my desired predictive value for my datas nns([1;99.63]),having the 2 input values&8 output values ,

this is i was finally got the error output in command window .

??? Error using ==> network.subsref at 83

Subscript indices must either be real positive integers or logicals.

pls tell solution for my problem………..

MATLAB does not allow indexing with numbers that are not real positive integers 1, 2, 3…n or logicals 0, 1. One of your inputs has a decimal => 99.63. Try to map the decimal inputs to some real’s instead for example i mapped the day names monday, tuesday… to integers 1, 2,…

my data were integers, and I had the same reference

sir, i have tried the same example, what you had posted here. . . but i dnt know how to import the data in excel as you had did here. i am using matlab r2008b, i dnt know how to import single column as you did. please help me sir. many thanks

First open the excel file using File -> Import Data, then select the desired column[s] and press the Import Button.

i was made changes,but i was not get the output,pls give some ideas……

hai sir ,this my program,from this program ,how i will get the desired predicted output ? pls help me sir………………………….

% Target Vector

T = [3 9 12 4 10 13 5];

% Input Vector

delaymat = toeplitz([3 0],T);

P = delaymat(2,:);

% Number of hidden neurons

S1 = 20;

% Create Network

net = newelm(P,T,S1);

% Train Network

Pseq = con2seq(P);

Tseq = con2seq(T);

net = train(net,Pseq,Tseq);

% Test the network

Y = sim(net,Pseq);

z = seq2con(Y);

diff1 = T – z{1,1};

I looked at your code and noticed that your are using two vectors, one for input and the other for target, this is why you have a neural net with one input and one output.

example vector = [2,3,4,5]

However you should be using a vector for input and a matrix for target

example vector = [2,3,4,5]

matrix = [3,4,5,6;9,5,7,8]

This will create a NN with 1 input and 2 outputs, it follows that a target matrix with n rows would create a NN with n outputs. Hope I have cleared things up for you.

if i want to get dataset in code then how i write my code

Hi Nirmal, could you be more specific with your question?

can u tell me sir,what is the acceptable error in neural network?

ganesh,

It depends on the level of accuracy that you require from the network, remember also that the error values may depend on the algo which is used to train the nn.

Hello,

I did everything that you said, but at the end I got this error when I tried to predict. I typed in command window this

CpNN([2;3]) and got this

??? Error using ==> network.subsref at 83

Index exceeds matrix dimensions

Please help

Thanks in advance

Hi,

Vladimir you may have missed step 9.

??? Error using ==> network.subsref at 83 / the same problem

Hi John and Vladimir, which version of MATLAB are you guys using?

2009b

Please try with 2011b, some things may work differently for 2009b

is there any testing data available as I have reviewed all the previous entries for training…

http://www.supremeventures.com/winningnumbersearch/cashpot/

i have try to download it but cant. where can i get this software. plz help

wat is the name of the software u guys using

MATLAB

i have try to download it but cant. where can i get this software. plz help

Yes, I also have 2009b, maybe that was the problem. Thanks for your answer

Glad to be of help Valdimir.

I tried with 2012b , and it really worked, thanks a lot.

You are welcome john

where did u guys download this from

Dear sir once i created the model using same procedure can I use this model on daily based prediciton and if yes what is the next step for that?

dear sir,

Please have a look on my past post..

Hi there,

I was wondering about how to use the model using this same method on daily base prediction.

where can i get this software can somebody help me

I’m having a problem with neural network forecasting in Matlab Neural Network Toolbox.

Let’s consider two datasets (1 hour timestamp):

input – weather forecast – temperature and cloudiness

target – water flow rate

I load data and train model.

Now my problem – how I can get forecasted values of water flow rate based on 24h weather forecast dataset (temp. and cloudiness)?

Hi oleg,

How are your input values arranged your input matrix? you should have a 3xn matrix.

Hi Romaine,

My values are arranged as below:

input – 26278×2 – [temperatue ; cloudiness]

target 26278×1 – [flow rate]

After I train the NARX model with input and output data, I would like to predict flow rate (24×1) for prepared 24-hour temperature and cloudiness forecast dataset (24×2). Is it possible? How can I do that?

Thank you for your quick response.

You need to transpose both matrices so that they become 2 x 26278 and 1 x 26278 then you can use that to train the network.

yournet([temp, cloudiness]) will give you a predicted value for flow rate.

I transformed my model into closed-loop to obtain multi-step predictions //netc=closeloop(net);//, but when I enter:

flow_rate_forecast=netc(weather_forecast);

the results are strange – all 24 flow values are the same 😦

I have no idea what I did wrong.

Are you using closeloop just because you want to get all 24 predictions at once? if so you should note that a closed-loop network feeds its output back into its inputs which may be the source of your problem. I do not have MATLAB installed at the moment so I am unable to do any testing with your code.

When I do this in the last step LotteryNN([1;1])

I get the following error.

ans =

Neural Network object:

architecture:

numInputs: 1

numInputs: 1

numLayers: 2

numLayers: 2

??? Error using ==> network.disp>boolstr

Too many input arguments.

Error in ==> network.disp at 35

fprintf(‘ biasConnect: %s\n’,boolstr(net.biasConnect));

Error in ==> network.display at 32

disp(net)

Could you suggest a solution?

Which version of MATLAB are you using?

You should have written clearly that it is FOR RESEARCH ONLY because some people here believe that neural network is some sort of magic mirror. It is not – if the game is purely random, the neural network will not detect ANYTHING. If there is some correlation in the game, for example machine is damaged, NN can detect something. But this can be also detected by any math software by self-correlation check.

So dear guys – play with this program but do not expect it will help you to win on lottery. If you do – this means you completly do not understand what is neural network and blindly copy paste is like magic box.

Hi there, it does state that in the disclaimer and also at the end of the post, however your comment will also add to the warning that this is FOR RESEARCH ONLY.

anyway good job, I will add it to my personal training

Just I noticed some comments here believing that NN is magic box so I decided to write this in capital letters again

Thanks for your feedback your comments are very insightful.

hi, I am designing a machine that will give change for purchases below R100 and it should give the number of notes and coins, also the notes and coins should be as few as possible. I thought of using a while loop but im confused as to how, please help

Sounds like knapsack problem

Just having a little FUN with the concept that neural network software could be used for lottery predictions. With that being said, I am new to the concept of neural networks and how the data should be setup for training or predictions. I am using the latest trial version of Matlab with the NNTool option and was hoping for a little help in understanding what is the target vs. input when setting up a 5/45 lottery game. For example, I want to analyze say the latest 50 draws and have the network output 20 of the best numbers to play after training. How would I set up the parameters? Thanks in advance.

David V is RIGHT!!! How to set up this MathLab NeuNet for a 5/45 GAME that Analyzes the past 50 DRAWS with an OUTPUT of 25 possible numbers (1 to 45) for a single future draw date/time

The principle remains the same however instead of cpTargets been a n x 1 vector you would need a n x 5 matrix to accommodate for the five possible numbers.

Thanks for the reply. Also how could I set this NeuNet MATLAB to RUN the Algorthm on a GPU nVidia CUDA Acceleration and event Network Parallel Computer setup instead of just the CPU and how? It would be nice if you made a youtube video that shows how to set this all up From Excel arrangement, to working MATLAB version install/config, to MATLAB Neural Net Setup/Training ! Also as a side question, what does your friends’ heuristics such as OldLady or FreashWater… stand for in each Cash Pot drawing? The number are different on for each FreashWater, OldLady draw time repetition, I dont see the corrolation between both OldLady or both FreashWater heuristics lol! THANKS!

There is a book that contains the numbers and their meanings; however, as you see I completely ignored that column because it’s just there to further complicate the heuristics. In terms of NN prediction they have no meaning or correlation.

The n x 5 vector would need to be also included it the previous 50 drawing for each column pick1, pick2, pick3, pick4, pick5, 5 hence vectors. A n x 5 trained target vectors but the output would have to be a n x 25 vectors? Am I getting it right that’s where I’m confused how to set this up?.

Since there are 5 possible numbers in the draw you could build a 5 x 25 matrix by running the NN 25 times in a loop, remember that in reality the draw is not run concurrently.