Lottery packagesI couldn’t resist an awful title.

I also couldn’t resist messing about making something that really is quite fantastically pointless to add to my growing collection of pointless things.

This pointless thing involves messing about with a sort of lottery type thing. Really I was just pondering how the lottery worked and how you could model that, I really need to find a hobby - such as having a job.

 

So for the sake of keeping things slightly complex there are three main draw type games available, Lotto, Euromillions and Thunderball (which disappointingly does not have a 007 ball). The games each work on the basic idea of drawing a number of main balls and then one or two bonus balls. In the case of Lotto all the drawn numbers come from the same set of balls where as EuroMillions and Thunderball use a separate set of balls for drawing the bonus numbers. Obviously the odds of winning are quite small I guess the reward of buying a ticket is to buy into the possibility of winning and the fantasies that it spawns.

I should buy some good sturdy boots, I’m good at rambling.

 

Anyway, time for boring code, I find it fills the page well –

package game;

import java.util.HashMap;
import java.util.Map;
import util.Rand;

/**
 *
 * @author Sam Woodfine <This email address is being protected from spambots. You need JavaScript enabled to view it. > 29-May-2014 11:30:46
 */
public abstract class Draw {

   
    private final int high; //highest number that can be drawn;
    private final int low; //lowest number that can be drawn;
    private Map<Integer, Integer> results = new HashMap<>();
    private final int draw; //how many numbers to draw;
    private Rand ran = new Rand();
    private final String gameName;
   
    public Draw(int high, int low, int toDraw, String gameName){
       
        this.high = high;
        this.low = low;
        this.draw = toDraw;
        this.gameName = gameName;
    }  
   
    public abstract boolean doGame();
   
    protected boolean doDraw(){
       

        for(int i = 0; i < getDraw(); i++){
           
           
            int drawn = this.getRandom();
           
            while(this.results.containsValue(drawn)){
               
                drawn = this.getRandom();
               
            }
           
            this.results.put(i + 1, drawn);
           
           
        }
       
        return true;
       
    }
   
    public void printResult(){
       
        System.out.println(this.getGameName());
        System.out.println();
       
        for(Integer bn : this.results.keySet()){
           
            System.out.print(" Ball " + bn + " = " + this.results.get(bn));
           
        }
       
        System.out.println();
       
    }
   
    public Map<Integer, Integer> getResults() {
        return new HashMap<>(results);
    }
   
    private void resetResults(){
        this.results = new HashMap<>();
    }

    protected int getHigh() {
        return high;
    }

    protected int getLow() {
        return low;
    }

    protected int getDraw() {
        return draw;
    }
   
    private int getRandom(){
        return this.ran.getNumber(this.getLow(), this.getHigh());
    }
   
    public String getGameName(){
        return this.gameName;
    }
   
}

 

Draw is the base class that is going to do the boring stuff so its abstract and generally rather a disappointing subject to write anything about. Rand is a utility class that does nothing but return a random int in the specified range, thrilling stuff I know. It is in a class of its own as I read that creating new instances of Random increased the likelihood that the random numbers would be from a limited range (not so random) and that keeping a single instance solved this. I don’t know if that is true, maybe I’ll find out later if I get bored.

 

Riding Draw like its dog on heat is the equally thrilling class BasicLottery –

package game;



/**
 *
 * @author Sam Woodfine <This email address is being protected from spambots. You need JavaScript enabled to view it. > 29-May-2014 15:28:01
 */
public class BasicLottery extends Draw{

    private boolean bonusSet;
    private int noBonus;
   
    public BasicLottery(int high, int low, int toDraw, String name, boolean bonusSet, int noBonus){
       
        super(high, low, toDraw, name);
        this.bonusSet = bonusSet;
        this.noBonus = noBonus;
    }

    @Override
    public boolean doGame() {
  
        this.doDraw();
        //this.printResult();

        return true;
       
    }
   
    public boolean getBonusSet(){
        return this.bonusSet;
    }

    public int getNoBonus(){
        return this.noBonus;
    }
}

No real shocks here, it just provides a simple working lottery as the name might suggest. For the sake of ease I extended this to make the Lotto game variant by doing nothing but calling the base class constructor with relevant variables, I’m a fan of making things difficult.

package game;

/**
 *
 * @author Sam Woodfine <This email address is being protected from spambots. You need JavaScript enabled to view it. > 29-May-2014 11:30:12
 */
public class Lotto extends BasicLottery {

    public Lotto(){
       
        super(49, 1, 7, "Lotto", false, 1);
       
    }

}

The draws that use multiple sets of balls are a bit more complicated to think about, or not. These variants can be handled by the following exciting class –

package game;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Sam Woodfine <This email address is being protected from spambots. You need JavaScript enabled to view it. > 29-May-2014 13:38:10
 */
public class ComplexLotto extends BasicLottery{
   
    private BasicLottery mainDraw;
    private BasicLottery bonusDraw;
   
    private int drawMain;
    private int drawBonus;
   
    private Map<Integer, Integer> results = new HashMap<>();
   
   
    public ComplexLotto(int mainHigh, int mainlow, int bonusHigh, int bonusLow, int drawMain, int drawBonus, String gameName){
       
        super(0, 0, 0, gameName, true, drawBonus);

        this.mainDraw = new BasicLottery(mainHigh, mainlow, drawMain,  gameName + " Helper", true, 0);
        this.bonusDraw = new BasicLottery(bonusHigh, bonusLow, drawBonus, gameName + " Helper", true, 0);
        this.drawMain = drawMain;
        this.drawBonus = drawBonus;
       
    }

    @Override
    public boolean doGame() {
       
        this.mainDraw.doDraw();
        this.bonusDraw.doDraw();
           
        this.results.putAll(this.mainDraw.getResults());
       
        Map<Integer, Integer> temp = this.bonusDraw.getResults();
       
        for(int i = 0; i < this.drawBonus; i++){
           
            //System.out.println(temp.get(i + 1));
           
            this.results.put(i + this.drawMain + 1, temp.get(i + 1));
        }
       
       

        return true;
    }

    @Override
    public void printResult(){
       
        System.out.println(this.getGameName());
        System.out.println();
       
        for(Integer bn : this.results.keySet()){
           
            System.out.print(" Ball " + bn + " = " + this.results.get(bn));
           
        }
       
        System.out.println();
       
    }
   
    @Override
    public Map<Integer, Integer> getResults(){
        return new HashMap<>(this.results);
    }
   
   
}

I called it complex to give it some gravitas.

Composition in action I guess I should point out, that’s got to score OO points. Obviously by making it extend BasicLottery I make life easier later on when I do something not very complicated but in fairness this is probably the technical highlight of this posting so I think I should make some effort to big it up a bit, alas I am not really managing that.

Basically it uses two BasicLottery’s to act as the two sets of balls and is itself an empty BasicLottery that does nothing but provide a useful interface. Sending in different values to the constructor lets the Euromillions and Thunderball games be simulated.

With those thrilling pieces to this puzzle in place it’s time to rock with an exciting Runnable class...oh yeah, cool Jazz. Well, not cool Jazz, more blues I think atm.....yeah, actually it’s time for an aside at this juncture.

As anyone reading this will have read the previous entry (Grr iTunes gRg) first (since people obviously read blogs in reverse chronological order) you’ll know that I got some new music and that it was a bit of hassle. I’m loving ‘Already Home’ at the moment, in general there is a constant risk of clapping along although this may only be because I have only listened to the tracks I purchased since I purchased them and it may be starting to impact on the little sanity I had retained from the experience of buying them. In fact I’m going to confess that I did check if they were doing any live dates in the UK but apparently not (or they already did).

 

So anyway, back to the point...

package results;

import game.BasicLottery;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Sam Woodfine <This email address is being protected from spambots. You need JavaScript enabled to view it. > 29-May-2014 16:00:42
 */
public class LottoThread implements Runnable{
   
   
    private BasicLottery lot;
    private long noDraws;
    private String gameName= "";
   
    private Map<Integer, Integer> results = new HashMap<>();
    private Map<Integer, Integer> bonusresults = new HashMap<>();
 
    public LottoThread(BasicLottery aLot, long noDraws){       
        this.lot = aLot;   
        this.noDraws = noDraws;
        this.gameName = aLot.getGameName();
    }

    @Override
    public void run() {
       
        for(long i = 0; i < noDraws; i++){
           
            this.lot.doGame();

            Map<Integer, Integer> temp = this.lot.getResults();
            boolean sepBonus = this.lot.getBonusSet();
           
           
            for(int j = 1; j < temp.size() + 1; j++){
               
                if(sepBonus){
                   
                    if(j > temp.size() - this.lot.getNoBonus() ){
                       
                        this.mapHelper(this.bonusresults, temp.get(j), 1);
                    }
                    else{
                        this.mapHelper(this.results, temp.get(j), 1);
                    }
                   
                }
                else{

                    if(j > temp.size() - this.lot.getNoBonus() ){

                        this.mapHelper(this.bonusresults, temp.get(j), 1);
                    }
                    else{
                        this.mapHelper(this.results, temp.get(j), 1);
                    }
                   
                }
               
               
            }
           
           
        }
       
        this.printStuff();

    }
   
    private void printStuff(){
       
        System.out.println(this.gameName);
       
        System.out.println("Main balls.....");
       
        for(Integer in : this.results.keySet()){
           
            System.out.println("Ball No: " + in + " was drawn " + this.results.get(in) + " times as a main ball.");
           
        }
       
        System.out.println("Bonus balls.....");
       
        for(Integer inn : this.bonusresults.keySet()){
           
            System.out.println("Ball No: " + inn + " was drawn " + this.bonusresults.get(inn) + " times as a bonus ball.");
           
        }
               
       
    }
   
    private void mapHelper(Map<Integer, Integer> toInsert, int key, int value){
       
        //....yeah but that doesnt mean that this isnt here
       
        if(toInsert.containsKey(key)){
           
            toInsert.put(key, value + toInsert.get(key));
           
        }
        else{
            toInsert.put(key, value);
        }
       
       
    }

}

As you can tell it takes a generic BasicLottery as an argument which is why the ComplexLotto class extended it.

What the run method does is really rather pointless. Really I should be doing some ninja probability calculating or professing how silly buying a lottery ticket is but as I am me and had read about the distribution of random numbers I set the run method to do something fairly pointless really.

It wouldn’t be massive effort to adapt this to do something useful of course. A thought I did have was to stick the draw results in a database and have my Raspberry Pi spend the rest of its life being a psychotic lottery draw machine, I still might do that if I can’t think of something else to occupy myself with – my fingers nails could use a trim so I have probably already managed that.

 

The printStuff method yields some feedback from this mess so we get to see how many times each ball was drawn.

 

For your entertainment I present to you the main class –

package lottery;

import game.BasicLottery;
import game.ComplexLotto;
import game.Lotto;
import results.LottoThread;

/**
 *
 * @author Sam Woodfine <This email address is being protected from spambots. You need JavaScript enabled to view it. >
 */
public class LotteryMain {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
        new LotteryMain().doSomeDraws(50000000);
       
    }
   
   
    public void doSomeDraws(long howManyDraws){
       
       
       
        BasicLottery aLot = new Lotto();
        BasicLottery eM = new ComplexLotto(50, 1, 11, 1, 5, 2, "EuroMillions");
        BasicLottery tB = new ComplexLotto(39, 1, 14, 1, 5, 1, "ThunderBall");
       
       
        Thread t = new Thread(new LottoThread(aLot, howManyDraws));
        Thread t1 = new Thread(new LottoThread(eM, howManyDraws));
        Thread t2 = new Thread(new LottoThread(tB, howManyDraws));
       
        t.start();
        t1.start();
        t2.start();
       
    }
   
}

The lazy joy of the Lotto class is obvious when compared to the hassle of creating the other two games.

Due to the nature of the games and the number of draws it does the results will be printed out in order of complexity (Lotto, ThunderBall, EuroMillions), the fewer the number of draws the more likely you get the print out in random order as I have done nothing to marshal the printing.

run:
Lotto
Main balls.....
Ball No: 1 was drawn 6121696 times as a main ball.
Ball No: 2 was drawn 6119138 times as a main ball.
Ball No: 3 was drawn 6123659 times as a main ball.
Ball No: 4 was drawn 6119708 times as a main ball.
Ball No: 5 was drawn 6119314 times as a main ball.
Ball No: 6 was drawn 6124860 times as a main ball.
Ball No: 7 was drawn 6118494 times as a main ball.
Ball No: 8 was drawn 6124970 times as a main ball.
Ball No: 9 was drawn 6123917 times as a main ball.
Ball No: 10 was drawn 6121953 times as a main ball.
Ball No: 11 was drawn 6120879 times as a main ball.
Ball No: 12 was drawn 6124009 times as a main ball.
Ball No: 13 was drawn 6120094 times as a main ball.
Ball No: 14 was drawn 6121613 times as a main ball.
Ball No: 15 was drawn 6119842 times as a main ball.
Ball No: 17 was drawn 6121256 times as a main ball.
Ball No: 16 was drawn 6124735 times as a main ball.
Ball No: 19 was drawn 6123105 times as a main ball.
Ball No: 18 was drawn 6121692 times as a main ball.
Ball No: 21 was drawn 6122548 times as a main ball.
Ball No: 20 was drawn 6123345 times as a main ball.
Ball No: 23 was drawn 6124530 times as a main ball.
Ball No: 22 was drawn 6119563 times as a main ball.
Ball No: 25 was drawn 6122730 times as a main ball.
Ball No: 24 was drawn 6122253 times as a main ball.
Ball No: 27 was drawn 6122835 times as a main ball.
Ball No: 26 was drawn 6122505 times as a main ball.
Ball No: 29 was drawn 6122088 times as a main ball.
Ball No: 28 was drawn 6123497 times as a main ball.
Ball No: 31 was drawn 6118844 times as a main ball.
Ball No: 30 was drawn 6124289 times as a main ball.
Ball No: 34 was drawn 6121917 times as a main ball.
Ball No: 35 was drawn 6121644 times as a main ball.
Ball No: 32 was drawn 6123093 times as a main ball.
Ball No: 33 was drawn 6120262 times as a main ball.
Ball No: 38 was drawn 6122757 times as a main ball.
Ball No: 39 was drawn 6121305 times as a main ball.
Ball No: 36 was drawn 6126779 times as a main ball.
Ball No: 37 was drawn 6124960 times as a main ball.
Ball No: 42 was drawn 6120012 times as a main ball.
Ball No: 43 was drawn 6125608 times as a main ball.
Ball No: 40 was drawn 6126023 times as a main ball.
Ball No: 41 was drawn 6123074 times as a main ball.
Ball No: 46 was drawn 6119169 times as a main ball.
Ball No: 47 was drawn 6120691 times as a main ball.
Ball No: 44 was drawn 6123258 times as a main ball.
Ball No: 45 was drawn 6124631 times as a main ball.
Ball No: 49 was drawn 6126729 times as a main ball.
Ball No: 48 was drawn 6124127 times as a main ball.
Bonus balls.....
Ball No: 1 was drawn 1020352 times as a bonus ball.
Ball No: 2 was drawn 1020506 times as a bonus ball.
Ball No: 3 was drawn 1020337 times as a bonus ball.
Ball No: 4 was drawn 1020574 times as a bonus ball.
Ball No: 5 was drawn 1023721 times as a bonus ball.
Ball No: 6 was drawn 1020467 times as a bonus ball.
Ball No: 7 was drawn 1021041 times as a bonus ball.
Ball No: 8 was drawn 1020544 times as a bonus ball.
Ball No: 9 was drawn 1020006 times as a bonus ball.
Ball No: 10 was drawn 1020909 times as a bonus ball.
Ball No: 11 was drawn 1021069 times as a bonus ball.
Ball No: 12 was drawn 1020550 times as a bonus ball.
Ball No: 13 was drawn 1019577 times as a bonus ball.
Ball No: 14 was drawn 1020261 times as a bonus ball.
Ball No: 15 was drawn 1020073 times as a bonus ball.
Ball No: 17 was drawn 1019634 times as a bonus ball.
Ball No: 16 was drawn 1021006 times as a bonus ball.
Ball No: 19 was drawn 1019529 times as a bonus ball.
Ball No: 18 was drawn 1020749 times as a bonus ball.
Ball No: 21 was drawn 1020848 times as a bonus ball.
Ball No: 20 was drawn 1020047 times as a bonus ball.
Ball No: 23 was drawn 1020148 times as a bonus ball.
Ball No: 22 was drawn 1020929 times as a bonus ball.
Ball No: 25 was drawn 1021272 times as a bonus ball.
Ball No: 24 was drawn 1019578 times as a bonus ball.
Ball No: 27 was drawn 1022027 times as a bonus ball.
Ball No: 26 was drawn 1019073 times as a bonus ball.
Ball No: 29 was drawn 1020709 times as a bonus ball.
Ball No: 28 was drawn 1020275 times as a bonus ball.
Ball No: 31 was drawn 1023095 times as a bonus ball.
Ball No: 30 was drawn 1020132 times as a bonus ball.
Ball No: 34 was drawn 1019430 times as a bonus ball.
Ball No: 35 was drawn 1020954 times as a bonus ball.
Ball No: 32 was drawn 1020948 times as a bonus ball.
Ball No: 33 was drawn 1020307 times as a bonus ball.
Ball No: 38 was drawn 1021162 times as a bonus ball.
Ball No: 39 was drawn 1021655 times as a bonus ball.
Ball No: 36 was drawn 1018511 times as a bonus ball.
Ball No: 37 was drawn 1018848 times as a bonus ball.
Ball No: 42 was drawn 1020783 times as a bonus ball.
Ball No: 43 was drawn 1018508 times as a bonus ball.
Ball No: 40 was drawn 1021433 times as a bonus ball.
Ball No: 41 was drawn 1021300 times as a bonus ball.
Ball No: 46 was drawn 1019097 times as a bonus ball.
Ball No: 47 was drawn 1019937 times as a bonus ball.
Ball No: 44 was drawn 1019900 times as a bonus ball.
Ball No: 45 was drawn 1019881 times as a bonus ball.
Ball No: 49 was drawn 1018332 times as a bonus ball.
Ball No: 48 was drawn 1019976 times as a bonus ball.
ThunderBall
Main balls.....
Ball No: 1 was drawn 6413194 times as a main ball.
Ball No: 2 was drawn 6413888 times as a main ball.
Ball No: 3 was drawn 6410596 times as a main ball.
Ball No: 4 was drawn 6407376 times as a main ball.
Ball No: 5 was drawn 6412382 times as a main ball.
Ball No: 6 was drawn 6411404 times as a main ball.
Ball No: 7 was drawn 6411390 times as a main ball.
Ball No: 8 was drawn 6408289 times as a main ball.
Ball No: 9 was drawn 6410311 times as a main ball.
Ball No: 10 was drawn 6412561 times as a main ball.
Ball No: 11 was drawn 6408959 times as a main ball.
Ball No: 12 was drawn 6411723 times as a main ball.
Ball No: 13 was drawn 6408063 times as a main ball.
Ball No: 14 was drawn 6409152 times as a main ball.
Ball No: 15 was drawn 6408448 times as a main ball.
Ball No: 17 was drawn 6406772 times as a main ball.
Ball No: 16 was drawn 6410264 times as a main ball.
Ball No: 19 was drawn 6409694 times as a main ball.
Ball No: 18 was drawn 6409113 times as a main ball.
Ball No: 21 was drawn 6411643 times as a main ball.
Ball No: 20 was drawn 6410648 times as a main ball.
Ball No: 23 was drawn 6413220 times as a main ball.
Ball No: 22 was drawn 6408871 times as a main ball.
Ball No: 25 was drawn 6411567 times as a main ball.
Ball No: 24 was drawn 6410807 times as a main ball.
Ball No: 27 was drawn 6409325 times as a main ball.
Ball No: 26 was drawn 6412176 times as a main ball.
Ball No: 29 was drawn 6408599 times as a main ball.
Ball No: 28 was drawn 6412347 times as a main ball.
Ball No: 31 was drawn 6404814 times as a main ball.
Ball No: 30 was drawn 6410543 times as a main ball.
Ball No: 34 was drawn 6408626 times as a main ball.
Ball No: 35 was drawn 6408158 times as a main ball.
Ball No: 32 was drawn 6411413 times as a main ball.
Ball No: 33 was drawn 6414690 times as a main ball.
Ball No: 38 was drawn 6407879 times as a main ball.
Ball No: 39 was drawn 6410160 times as a main ball.
Ball No: 36 was drawn 6410216 times as a main ball.
Ball No: 37 was drawn 6410719 times as a main ball.
Bonus balls.....
Ball No: 1 was drawn 3569536 times as a bonus ball.
Ball No: 2 was drawn 3575269 times as a bonus ball.
Ball No: 3 was drawn 3571176 times as a bonus ball.
Ball No: 4 was drawn 3573552 times as a bonus ball.
Ball No: 5 was drawn 3571842 times as a bonus ball.
Ball No: 6 was drawn 3565730 times as a bonus ball.
Ball No: 7 was drawn 3573852 times as a bonus ball.
Ball No: 8 was drawn 3572289 times as a bonus ball.
Ball No: 9 was drawn 3571043 times as a bonus ball.
Ball No: 10 was drawn 3569777 times as a bonus ball.
Ball No: 11 was drawn 3572417 times as a bonus ball.
Ball No: 12 was drawn 3570626 times as a bonus ball.
Ball No: 13 was drawn 3570349 times as a bonus ball.
Ball No: 14 was drawn 3572542 times as a bonus ball.
EuroMillions
Main balls.....
Ball No: 1 was drawn 4998276 times as a main ball.
Ball No: 2 was drawn 4998690 times as a main ball.
Ball No: 3 was drawn 5000683 times as a main ball.
Ball No: 4 was drawn 5003641 times as a main ball.
Ball No: 5 was drawn 5002953 times as a main ball.
Ball No: 6 was drawn 4995828 times as a main ball.
Ball No: 7 was drawn 4999627 times as a main ball.
Ball No: 8 was drawn 4998723 times as a main ball.
Ball No: 9 was drawn 4997456 times as a main ball.
Ball No: 10 was drawn 5000609 times as a main ball.
Ball No: 11 was drawn 4998204 times as a main ball.
Ball No: 12 was drawn 5001360 times as a main ball.
Ball No: 13 was drawn 4999891 times as a main ball.
Ball No: 14 was drawn 5001812 times as a main ball.
Ball No: 15 was drawn 4999649 times as a main ball.
Ball No: 17 was drawn 5000646 times as a main ball.
Ball No: 16 was drawn 5002428 times as a main ball.
Ball No: 19 was drawn 5000097 times as a main ball.
Ball No: 18 was drawn 4998056 times as a main ball.
Ball No: 21 was drawn 4997885 times as a main ball.
Ball No: 20 was drawn 4997920 times as a main ball.
Ball No: 23 was drawn 4995736 times as a main ball.
Ball No: 22 was drawn 5001195 times as a main ball.
Ball No: 25 was drawn 5001954 times as a main ball.
Ball No: 24 was drawn 5002837 times as a main ball.
Ball No: 27 was drawn 4998501 times as a main ball.
Ball No: 26 was drawn 4998464 times as a main ball.
Ball No: 29 was drawn 4997968 times as a main ball.
Ball No: 28 was drawn 5001060 times as a main ball.
Ball No: 31 was drawn 5001285 times as a main ball.
Ball No: 30 was drawn 4999429 times as a main ball.
Ball No: 34 was drawn 5000551 times as a main ball.
Ball No: 35 was drawn 5003374 times as a main ball.
Ball No: 32 was drawn 5001192 times as a main ball.
Ball No: 33 was drawn 4997130 times as a main ball.
Ball No: 38 was drawn 5003606 times as a main ball.
Ball No: 39 was drawn 4999110 times as a main ball.
Ball No: 36 was drawn 4998328 times as a main ball.
Ball No: 37 was drawn 5001874 times as a main ball.
Ball No: 42 was drawn 4997484 times as a main ball.
Ball No: 43 was drawn 5002681 times as a main ball.
Ball No: 40 was drawn 4998781 times as a main ball.
Ball No: 41 was drawn 5002514 times as a main ball.
Ball No: 46 was drawn 5000911 times as a main ball.
Ball No: 47 was drawn 5000191 times as a main ball.
Ball No: 44 was drawn 4999455 times as a main ball.
Ball No: 45 was drawn 5002059 times as a main ball.
Ball No: 50 was drawn 4998120 times as a main ball.
Ball No: 49 was drawn 5000440 times as a main ball.
Ball No: 48 was drawn 4999336 times as a main ball.
Bonus balls.....
Ball No: 1 was drawn 9091271 times as a bonus ball.
Ball No: 2 was drawn 9090757 times as a bonus ball.
Ball No: 3 was drawn 9087777 times as a bonus ball.
Ball No: 4 was drawn 9088866 times as a bonus ball.
Ball No: 5 was drawn 9093766 times as a bonus ball.
Ball No: 6 was drawn 9095129 times as a bonus ball.
Ball No: 7 was drawn 9090087 times as a bonus ball.
Ball No: 8 was drawn 9088720 times as a bonus ball.
Ball No: 9 was drawn 9086993 times as a bonus ball.
Ball No: 10 was drawn 9096093 times as a bonus ball.
Ball No: 11 was drawn 9090541 times as a bonus ball.
BUILD SUCCESSFUL (total time: 3 minutes 7 seconds)

Basically as you can see you do get a pretty much entirely even distribution of values which shouldn’t be a shock. My pondering on this is whether that really equates to be being random; I accept that really this is pseudo random. What I wonder is if it is actually possible in Java using this method for ball 1 to be drawn every time, that should be possible. I suppose what is most useful is having an even distribution of random numbers, it would probably be irritating if it did randomly produce the same number (or few numbers) and never any others.

Now for something interesting, alternatively you can keep reading.

 

As you have read this blog backwards you’ll remember this picture of iTunes using a fair wad of resources to do nothing –

iTunes crashing

This is the usage (for comparison) of the lottery program, Eve and iTunes (running normally). I have no idea why that would be relevant for anyone to see but here it is anyway –

Stuff running

I do hope you retained self control whilst viewing those raunchy task manager images. Yes, I did add a few columns, it makes it look clever.

 

To make this look like it was all done for some clever purpose here are the results if a new Random is created each time rather than re-used.

run:
Lotto
Main balls.....
Ball No: 1 was drawn 6121353 times as a main ball.
Ball No: 2 was drawn 6122822 times as a main ball.
Ball No: 3 was drawn 6120894 times as a main ball.
Ball No: 4 was drawn 6122345 times as a main ball.
Ball No: 5 was drawn 6122520 times as a main ball.
Ball No: 6 was drawn 6120983 times as a main ball.
Ball No: 7 was drawn 6121614 times as a main ball.
Ball No: 8 was drawn 6123578 times as a main ball.
Ball No: 9 was drawn 6120773 times as a main ball.
Ball No: 10 was drawn 6121988 times as a main ball.
Ball No: 11 was drawn 6120646 times as a main ball.
Ball No: 12 was drawn 6122331 times as a main ball.
Ball No: 13 was drawn 6122462 times as a main ball.
Ball No: 14 was drawn 6120619 times as a main ball.
Ball No: 15 was drawn 6123619 times as a main ball.
Ball No: 17 was drawn 6120846 times as a main ball.
Ball No: 16 was drawn 6121966 times as a main ball.
Ball No: 19 was drawn 6124254 times as a main ball.
Ball No: 18 was drawn 6122954 times as a main ball.
Ball No: 21 was drawn 6122930 times as a main ball.
Ball No: 20 was drawn 6123493 times as a main ball.
Ball No: 23 was drawn 6126064 times as a main ball.
Ball No: 22 was drawn 6124823 times as a main ball.
Ball No: 25 was drawn 6122729 times as a main ball.
Ball No: 24 was drawn 6122307 times as a main ball.
Ball No: 27 was drawn 6124059 times as a main ball.
Ball No: 26 was drawn 6123506 times as a main ball.
Ball No: 29 was drawn 6124325 times as a main ball.
Ball No: 28 was drawn 6123421 times as a main ball.
Ball No: 31 was drawn 6119804 times as a main ball.
Ball No: 30 was drawn 6121603 times as a main ball.
Ball No: 34 was drawn 6118575 times as a main ball.
Ball No: 35 was drawn 6126453 times as a main ball.
Ball No: 32 was drawn 6120453 times as a main ball.
Ball No: 33 was drawn 6124166 times as a main ball.
Ball No: 38 was drawn 6121441 times as a main ball.
Ball No: 39 was drawn 6121394 times as a main ball.
Ball No: 36 was drawn 6120470 times as a main ball.
Ball No: 37 was drawn 6124571 times as a main ball.
Ball No: 42 was drawn 6122495 times as a main ball.
Ball No: 43 was drawn 6122888 times as a main ball.
Ball No: 40 was drawn 6120810 times as a main ball.
Ball No: 41 was drawn 6118527 times as a main ball.
Ball No: 46 was drawn 6125052 times as a main ball.
Ball No: 47 was drawn 6120772 times as a main ball.
Ball No: 44 was drawn 6123956 times as a main ball.
Ball No: 45 was drawn 6124124 times as a main ball.
Ball No: 49 was drawn 6121198 times as a main ball.
Ball No: 48 was drawn 6125024 times as a main ball.
Bonus balls.....
Ball No: 1 was drawn 1020849 times as a bonus ball.
Ball No: 2 was drawn 1019710 times as a bonus ball.
Ball No: 3 was drawn 1021235 times as a bonus ball.
Ball No: 4 was drawn 1020716 times as a bonus ball.
Ball No: 5 was drawn 1020117 times as a bonus ball.
Ball No: 6 was drawn 1021479 times as a bonus ball.
Ball No: 7 was drawn 1020056 times as a bonus ball.
Ball No: 8 was drawn 1022334 times as a bonus ball.
Ball No: 9 was drawn 1017749 times as a bonus ball.
Ball No: 10 was drawn 1019765 times as a bonus ball.
Ball No: 11 was drawn 1020842 times as a bonus ball.
Ball No: 12 was drawn 1021608 times as a bonus ball.
Ball No: 13 was drawn 1020679 times as a bonus ball.
Ball No: 14 was drawn 1020654 times as a bonus ball.
Ball No: 15 was drawn 1020045 times as a bonus ball.
Ball No: 17 was drawn 1019761 times as a bonus ball.
Ball No: 16 was drawn 1020246 times as a bonus ball.
Ball No: 19 was drawn 1019900 times as a bonus ball.
Ball No: 18 was drawn 1019768 times as a bonus ball.
Ball No: 21 was drawn 1022042 times as a bonus ball.
Ball No: 20 was drawn 1020877 times as a bonus ball.
Ball No: 23 was drawn 1019366 times as a bonus ball.
Ball No: 22 was drawn 1021073 times as a bonus ball.
Ball No: 25 was drawn 1020404 times as a bonus ball.
Ball No: 24 was drawn 1021182 times as a bonus ball.
Ball No: 27 was drawn 1021067 times as a bonus ball.
Ball No: 26 was drawn 1019642 times as a bonus ball.
Ball No: 29 was drawn 1020358 times as a bonus ball.
Ball No: 28 was drawn 1018914 times as a bonus ball.
Ball No: 31 was drawn 1020373 times as a bonus ball.
Ball No: 30 was drawn 1021175 times as a bonus ball.
Ball No: 34 was drawn 1019156 times as a bonus ball.
Ball No: 35 was drawn 1020020 times as a bonus ball.
Ball No: 32 was drawn 1020488 times as a bonus ball.
Ball No: 33 was drawn 1019680 times as a bonus ball.
Ball No: 38 was drawn 1019549 times as a bonus ball.
Ball No: 39 was drawn 1022109 times as a bonus ball.
Ball No: 36 was drawn 1020939 times as a bonus ball.
Ball No: 37 was drawn 1019714 times as a bonus ball.
Ball No: 42 was drawn 1020570 times as a bonus ball.
Ball No: 43 was drawn 1020273 times as a bonus ball.
Ball No: 40 was drawn 1019917 times as a bonus ball.
Ball No: 41 was drawn 1020871 times as a bonus ball.
Ball No: 46 was drawn 1018938 times as a bonus ball.
Ball No: 47 was drawn 1020208 times as a bonus ball.
Ball No: 44 was drawn 1020727 times as a bonus ball.
Ball No: 45 was drawn 1020667 times as a bonus ball.
Ball No: 49 was drawn 1020994 times as a bonus ball.
Ball No: 48 was drawn 1021194 times as a bonus ball.
ThunderBall
Main balls.....
Ball No: 1 was drawn 6410790 times as a main ball.
Ball No: 2 was drawn 6411843 times as a main ball.
Ball No: 3 was drawn 6410856 times as a main ball.
Ball No: 4 was drawn 6411505 times as a main ball.
Ball No: 5 was drawn 6412958 times as a main ball.
Ball No: 6 was drawn 6406434 times as a main ball.
Ball No: 7 was drawn 6413212 times as a main ball.
Ball No: 8 was drawn 6409625 times as a main ball.
Ball No: 9 was drawn 6410127 times as a main ball.
Ball No: 10 was drawn 6413148 times as a main ball.
Ball No: 11 was drawn 6411859 times as a main ball.
Ball No: 12 was drawn 6407874 times as a main ball.
Ball No: 13 was drawn 6410007 times as a main ball.
Ball No: 14 was drawn 6409036 times as a main ball.
Ball No: 15 was drawn 6411179 times as a main ball.
Ball No: 17 was drawn 6407861 times as a main ball.
Ball No: 16 was drawn 6405852 times as a main ball.
Ball No: 19 was drawn 6409113 times as a main ball.
Ball No: 18 was drawn 6409203 times as a main ball.
Ball No: 21 was drawn 6410616 times as a main ball.
Ball No: 20 was drawn 6408819 times as a main ball.
Ball No: 23 was drawn 6407893 times as a main ball.
Ball No: 22 was drawn 6410553 times as a main ball.
Ball No: 25 was drawn 6407608 times as a main ball.
Ball No: 24 was drawn 6412543 times as a main ball.
Ball No: 27 was drawn 6407783 times as a main ball.
Ball No: 26 was drawn 6409880 times as a main ball.
Ball No: 29 was drawn 6409211 times as a main ball.
Ball No: 28 was drawn 6410384 times as a main ball.
Ball No: 31 was drawn 6413489 times as a main ball.
Ball No: 30 was drawn 6408487 times as a main ball.
Ball No: 34 was drawn 6408981 times as a main ball.
Ball No: 35 was drawn 6413072 times as a main ball.
Ball No: 32 was drawn 6410862 times as a main ball.
Ball No: 33 was drawn 6405831 times as a main ball.
Ball No: 38 was drawn 6414567 times as a main ball.
Ball No: 39 was drawn 6411727 times as a main ball.
Ball No: 36 was drawn 6415243 times as a main ball.
Ball No: 37 was drawn 6409969 times as a main ball.
Bonus balls.....
Ball No: 1 was drawn 3571716 times as a bonus ball.
Ball No: 2 was drawn 3571909 times as a bonus ball.
Ball No: 3 was drawn 3568926 times as a bonus ball.
Ball No: 4 was drawn 3572658 times as a bonus ball.
Ball No: 5 was drawn 3570640 times as a bonus ball.
Ball No: 6 was drawn 3571029 times as a bonus ball.
Ball No: 7 was drawn 3573523 times as a bonus ball.
Ball No: 8 was drawn 3573848 times as a bonus ball.
Ball No: 9 was drawn 3566789 times as a bonus ball.
Ball No: 10 was drawn 3572686 times as a bonus ball.
Ball No: 11 was drawn 3570969 times as a bonus ball.
Ball No: 12 was drawn 3573153 times as a bonus ball.
Ball No: 13 was drawn 3568294 times as a bonus ball.
Ball No: 14 was drawn 3573860 times as a bonus ball.
EuroMillions
Main balls.....
Ball No: 1 was drawn 4996976 times as a main ball.
Ball No: 2 was drawn 4998515 times as a main ball.
Ball No: 3 was drawn 4999809 times as a main ball.
Ball No: 4 was drawn 4999331 times as a main ball.
Ball No: 5 was drawn 4999618 times as a main ball.
Ball No: 6 was drawn 5000095 times as a main ball.
Ball No: 7 was drawn 4997851 times as a main ball.
Ball No: 8 was drawn 4999490 times as a main ball.
Ball No: 9 was drawn 4999892 times as a main ball.
Ball No: 10 was drawn 4999281 times as a main ball.
Ball No: 11 was drawn 5000540 times as a main ball.
Ball No: 12 was drawn 4999935 times as a main ball.
Ball No: 13 was drawn 4998638 times as a main ball.
Ball No: 14 was drawn 5001105 times as a main ball.
Ball No: 15 was drawn 4996969 times as a main ball.
Ball No: 17 was drawn 4996613 times as a main ball.
Ball No: 16 was drawn 4999637 times as a main ball.
Ball No: 19 was drawn 5004089 times as a main ball.
Ball No: 18 was drawn 5000338 times as a main ball.
Ball No: 21 was drawn 4999797 times as a main ball.
Ball No: 20 was drawn 5000961 times as a main ball.
Ball No: 23 was drawn 4999811 times as a main ball.
Ball No: 22 was drawn 4998898 times as a main ball.
Ball No: 25 was drawn 5001039 times as a main ball.
Ball No: 24 was drawn 5001412 times as a main ball.
Ball No: 27 was drawn 4998162 times as a main ball.
Ball No: 26 was drawn 5000551 times as a main ball.
Ball No: 29 was drawn 4999659 times as a main ball.
Ball No: 28 was drawn 4996381 times as a main ball.
Ball No: 31 was drawn 4999658 times as a main ball.
Ball No: 30 was drawn 5002159 times as a main ball.
Ball No: 34 was drawn 5003984 times as a main ball.
Ball No: 35 was drawn 5000362 times as a main ball.
Ball No: 32 was drawn 4999629 times as a main ball.
Ball No: 33 was drawn 5000509 times as a main ball.
Ball No: 38 was drawn 5000169 times as a main ball.
Ball No: 39 was drawn 4998226 times as a main ball.
Ball No: 36 was drawn 5002088 times as a main ball.
Ball No: 37 was drawn 5003158 times as a main ball.
Ball No: 42 was drawn 5000048 times as a main ball.
Ball No: 43 was drawn 4999296 times as a main ball.
Ball No: 40 was drawn 5004133 times as a main ball.
Ball No: 41 was drawn 4999953 times as a main ball.
Ball No: 46 was drawn 5001515 times as a main ball.
Ball No: 47 was drawn 5000281 times as a main ball.
Ball No: 44 was drawn 4999045 times as a main ball.
Ball No: 45 was drawn 5000274 times as a main ball.
Ball No: 50 was drawn 5001214 times as a main ball.
Ball No: 49 was drawn 4998831 times as a main ball.
Ball No: 48 was drawn 5000075 times as a main ball.
Bonus balls.....
Ball No: 1 was drawn 9088300 times as a bonus ball.
Ball No: 2 was drawn 9092871 times as a bonus ball.
Ball No: 3 was drawn 9089641 times as a bonus ball.
Ball No: 4 was drawn 9089563 times as a bonus ball.
Ball No: 5 was drawn 9088819 times as a bonus ball.
Ball No: 6 was drawn 9093949 times as a bonus ball.
Ball No: 7 was drawn 9090128 times as a bonus ball.
Ball No: 8 was drawn 9091886 times as a bonus ball.
Ball No: 9 was drawn 9088013 times as a bonus ball.
Ball No: 10 was drawn 9094780 times as a bonus ball.
Ball No: 11 was drawn 9092050 times as a bonus ball.
BUILD SUCCESSFUL (total time: 4 minutes 40 seconds)

I’m not sure that I can see a difference but then it is really boring to look at. Offhand the only interesting thing seems to be additional amount of run time the creation of the Random object adds.

 

Anyway, must get on and plant a flower, plant a Rose, I can plant anyone of those – apparently, although I don't know any man from Milwaukee.