Home > Programming, Uncategorized > Your personal Lotto quick pick

Your personal Lotto quick pick

Wanna improve your chances on winning a few million rupees?

The Mauritian Lotto was first introduced on the 07th of November 2009 by lottotech. The first jackpot was Rs 12 Million. The first winner of the lotto was Guillyano Zamir, who won the Rs 30 Million Jackpot. I am going to post the source code of a program i made that generate an arbitrary number of Lotto simulations. While writing this blog post, i researched a bit on Lotto and found some very interesting stuff.

Lotto lets you pick a certain number of choices from a card. In Mauritius you get to pick 6 numbers from a card having 40 numbers. Then, the Lotto managers pick 6 numbers at random. If your choice exactly matches theirs, you win a few million rupees or so. What is the probability of having a winning pick? Mathematics says the following about it: (40 × 39 × 38 × 37 × 36 × 35) / (6!) = 3,838,380. You have 1 chance in 3,838,380 of picking all 6 numbers correct! Actually it is not so huge. Some other countries or states have probability of over 20 million to 1 in winning their Lotto game. But this also equates to more frequent winners and lesser jackpot stakes.

There exists techniques and strategies for playing Lotto. The strategies are based on mathematics and logic. With techniques such as tracking, wheeling and pooling, you may be able to improve your odds. (Click on the hypertext link to read more about them).

How to Win the Lotto?
Basically, you can’t. Random draw lotteries are VERY carefully designed not to be predictable. And any ‘system’ is basically claiming to be able to predict results. Well best option is to gather a group of 10 people or so and play every combinations possible (3,838,380) then you split the gains. Lol, even if you do this, you are not sure you will be able to make a profit margin. I found some ‘systems’ on the internet claiming they improve your chances, significantly. Check out the following links: 1 | 2 | 3 | 4 | 5.

At Last: Your personal lotto quick pick
That was my primary aim for this post. A program that can generate your own-tweaked personal quick pick. I used Python to write it. It is not difficult to code. Yes, a function that successfully predicts the winning picks themselves would be more useful, but Python, although powerful, has yet to implement psychic faculties. Note that there exist a lot of software (some are shareware actually) that enable you create your own strategy and then generate numbers. They also enable you to analyze the numbers and derive conclusions of all sorts. Here are a few:

  • Odd/Even Analysis, which is where you determine the frequency of odd or even numbers.
  • Pairs/Doubles Analysis, which is determining the frequency of certain numbers appearing together.
  • Pick 3 and Pick 4 positions, such as in which position–first, second, or third–the digit 5 most frequently hits.
  • Sector Analysis, which is tracking how frequently numbers in the low sector hit, how many in the midrange sector hit, and how many in the higher range hit. For instance, if you’re playing a 6/40 Lotto and believe the numbers will be midrange, you might choose 14, 16, 17, 19, 22, and 28.

Here i made a random generator program and that counts the number of times there were 3 even numbers and 3 odd numbers in an arbitrary number of simulations. And it gives you its percentage. In my program i made 1000 simulations. You can change this of course to your own. Actually this was a practical test and had 2 hours to complete it! 2hrs may seemed a lot of time but actually it was in the first year, first semester. It was by far the coolest test i did so far in my course! Very few (actually i don’t know anyone) fininshed it completely without any flaws. I took my entire 2 hrs to do it. I did a mistake though, but a honest one, i wrongly used the random.randrange() library function, it just never generated the number 40 in the simulations.

You will need to generate random numbers for this. Generating true random numbers is a very complicated process and is an area of active researchin computer science. Python has pseudo-random number generator. It is called pseudo-random because it make use of an algorithm (MersenneTwister algorithm for that matter) to generate them. Well, you can make your own ;). You can use the random.randrange([start], stop[, step]) which return a randomly selected element from range(start, stop, step). Note that stop is non-inclusive. So we are ready to get our hands dirty.

Here is the Program listing

# roshans89

simulations = 1000 # Number Of simulations. Change only this variable.

from random import randrange

def simulate():

    # Declare all variables
    generated_number = []
    count = 0
    c_odd,c_even = 0,0

    while True:
        if count == 6: break

        a = randrange(1,41)

        if (a in generated_number):
            continue # Skip rest of loop and loop again from start

        generated_number.append(a)

        if a % 2 == 0:
            c_even += 1
        else:
            c_odd += 1

        if c_even == c_odd: #3 times
            num_times = 1
        else:
            num_times = 0
        
        count += 1


    return generated_number, c_even, c_odd, num_times

# Program start executing here

print "game\tWinning Numbers"
print "----\t---------------"

count = 1
times = 0

while count <= (simulations):
    r, c_even, c_odd, num_times = simulate()
    print count,"\t%d, %d, %d, %d, %d, %d" % (r[0],r[1],r[2],r[3],r[4],r[5])

    if num_times == 1:
        times += 1

    count += 1

print """
Number of times there were 3 odds and 3 evens: %d
Percentage Of time there were 3 odds and 3 evens: %.02f%s
""" % (times, (times/float(simulations) * 100), "%")


Here’s a sample run

game	Winning Numbers
----	---------------
1 	 11, 28, 39, 17, 4, 20
2 	 39, 6, 15, 34, 8, 31
3 	 38, 2, 12, 27, 30, 15
4 	 8, 16, 6, 18, 34, 40
5 	 21, 19, 14, 2, 11, 34
6 	 8, 21, 25, 5, 39, 23
7 	 5, 30, 16, 27, 10, 26
8 	 20, 35, 7, 31, 27, 29
9 	 4, 10, 2, 28, 3, 37
10 	 34, 3, 19, 22, 8, 11
.
.
.
997 	37, 20, 10, 35, 21, 15
998 	29, 27, 9, 7, 13, 20
999 	1, 13, 19, 5, 21, 32
1000 	25, 3, 7, 14, 34, 33

Number of times there were 3 odds and 3 evens: 345
Percentage Of time there were 3 odds and 3 evens: 34.50%

Program Notes:
You can change the simulations variable to your liking of course. Note that it took about 8 seconds to generate the output in my Intel 2.76 core 2 duo. I am sure there are faster algorithms to generate this. But performance is not an issue here 🙂 . The tricky part of the program is [obviously] you can’t generate the same number more that one time in a simulation. To resolve this, i generated a number and store it in an array (actually in Python it is list not array). Then i generate another number and check if it is in the list. If it not already in the list i can safely append in to the list else i ignore it and generate another number and then append it if it is not already in the list. This is what the following does

a = randrange(1,41)

if (a in generated_number):
continue # Skip rest of loop and loop again from start

generated_number.append(a)

Then i check all the numbers that i appended if it is even or odd and keep a count. If even == odd, i.e., got 3 even number and 3 odd number then i add it to the count of a variable which keeps the number of evens = odds (that variable is called times in my program). Finally i printed the % Of time there were 3 odds and 3 evens. It is just times/simulations * 100.

Notice that it will always display the percentage between 30% and 36%, the most frequent one being 33%. There could be some outliers, but i never actually encountered one. This percentage figure is questionable. Because as i said above Python uses the MersenneTwister algorithm to generate a random number. It is not a True random number.

By the way here are the previous lottotech results if want to make your own statistics and predictions:

Num Draw Date Winning Numbers Order Drawn
034 26-Jun-2010 21-25-28-33-35-40 25-33-21-28-40-35
033 19-Jun-2010 07-14-27-28-38-40 14-07-38-28-27-40
032 12-Jun-2010 01-09-23-35-36-39 01-35-39-09-36-23
031 05-Jun-2010 01-07-15-21-23-27 23-27-21-07-01-15
030 29-May-2010 06-21-25-27-38-39 21-06-27-25-39-38
029 22-May-2010 11-14-21-23-31-35 31-11-14-21-35-23
028 15-May-2010 01-06-13-16-20-26 16-01-26-13-20-06
027 08-May-2010 06-08-23-30-32-33 06-33-32-23-08-30
026 01-May-2010 03-04-14-23-25-28 23-04-25-14-28-03
025 24-Apr-2010 02-05-26-31-36-38 31-05-02-38-26-36
024 17-Apr-2010 08-14-21-26-34-36 34-21-14-08-26-36
023 10-Apr-2010 01-11-16-17-18-31 11-16-18-17-31-01
022 03-Apr-2010 03-11-19-20-30-32 19-30-20-03-11-32
021 27-Mar-2010 06-11-12-27-39-40 39-12-11-06-40-27
020 20-Mar-2010 01-09-11-26-34-35 34-01-11-09-26-35
019 13-Mar-2010 02-04-06-09-19-29
018 06-Mar-2010 23-29-31-32-35-40 35-32-23-40-31-29
017 27-Feb-2010 05-08-13-23-26-36 05-08-23-36-26-13
016 20-Feb-2010 07-11-24-25-31-39 39-25-07-24-11-31
015 13-Feb-2010 01-06-12-14-18-40 14-18-06-01-12-40
014 06-Feb-2010 08-15-16-17-20-26 26-08-20-16-17-15
013 30-Jan-2010 08-13-17-23-25-38 38-25-17-23-13-08
012 23-Jan-2010 04-09-12-19-30-40 40-19-04-12-30-09
011 16-Jan-2010 12-15-28-30-34-39 39-12-34-28-30-15
010 09-Jan-2010 08-10-24-26-27-36
009 02-Jan-2010 07-17-27-29-34-37
008 26-Dec-2009 07-08-09-15-18-30
007 19-Dec-2009 01-07-25-31-38-40
006 12-Dec-2009 26-27-29-30-36-39
005 05-Dec-2009 05-10-14-26-37-39
004 28-Nov-2009 03-11-12-26-32-38
003 21-Nov-2009 08-15-21-22-28-31
002 14-Nov-2009 02-03-04-11-16-34
001 07-Nov-2009 07-10-20-21-28-34

Data obtained from this link

Note that you are free to modify my program or distribute it, but please give me due credit.

Hope you enjoyed this post, replies as always are most welcomed. 🙂

–roshans89

Advertisements
  1. Princess
    July 14, 2010 at 7:38 pm

    uff…..otan long…..to pa ti cav fer 1 summary ta?? enfin….fer tou to bane analyses sipaki…kan ggane jackpot la…asT 1 cote dor pu mwa!! u still owe me!!!

    • July 14, 2010 at 7:46 pm

      Na, li pas sa long la do.. table la ek program la in fer li vin long 😛 ki cote d’or? 😛 Mne fini blier mwaa.. tro bel lepok sa zistoire la lol.

    • Red devils
      December 29, 2012 at 9:26 am

      Roshan dne mw les 6 numero gagnan 2 ce cemaine!!!!!

      • December 29, 2012 at 7:33 pm

        Malheureusement mo pas pratik la Magie noire 😛

  2. judexy22
    April 16, 2012 at 7:50 am

    I am amazed with Mauritians when I think of the Probability of winning 6 out of 40, and how there is a jackpot Winner almost every month ! How do you do that, Winners ?

    • April 30, 2012 at 3:08 pm

      lol… I think they are lucky 😛 Many play quite a lot of games for a week (5 games in a lotto form), most people i know play all 5s.. + other forms. I think that’s y 😛

  3. Deep Ganga
    August 26, 2012 at 3:59 pm

    Bonjour,

    Je voudrai savoir si vous pouvez m’aider

    Je voudrai que sur les 6 numero que 4 soi fixe et les 2 autres sont aleatoire sur allons dire

    Quelles sont les differents combinations possibles

    Merci

    Bien a vous

    Deep

  4. August 26, 2012 at 4:14 pm

    36/2 * 35 /1 = 630.
    Je crois.. 😛

  5. October 19, 2012 at 12:13 am

    I needed to draft you this little bit of word so as to give many thanks as before regarding the stunning thoughts you have shown on this
    site. This has been so shockingly generous with people like you to present without restraint what many people would have offered as an electronic book to
    make some bucks on their own, certainly now that you might well have tried it if you wanted.
    Those basics additionally worked to be the great way to be certain
    that many people have the identical dreams like my personal own to understand whole lot more when considering this condition.
    I think there are a lot more pleasurable opportunities up front for individuals that go through your blog.

  6. Aiko
    November 9, 2012 at 3:01 pm

    Hi Roshan!
    Your theory is good, but if the person who is creating the number use his /her lucky number, then the chance increases,and if lotterie mauritius don’t (mandai) then anybody with its chances can win!
    Best software is Lottra 3.5.0.0 (use LA Lotto as reference) Create your world!

  7. drayantee sooppan
    August 19, 2014 at 1:46 pm

    Can I have any contact with you

  8. adarsh
    September 10, 2016 at 12:42 pm

    how can i contact u?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: