Lotto Part 01

Background

The data for this R script comes from Tatts.com (Australia) and SingaporePools.com.sg (Singapore). There are FOUR (4) files in CSV
format from Tatts.com:

(1) powerball.csv
(2) ozlotto.csv
(3) satlotto.csv
(4) wedlotto.csv.

These files are easily read into R using the read.csv() function.

However, for SingaporePools.com.sg, there are NO CSV files, hence we have to scrape the results from the web page using the XML
package. The data is saved into TWO (2) CSV files:

(1) toto.csv
(2) 4d.csv.

source("C:/Users/denbrige/100 FxOption/103 FxOptionVerBack/080 Fx Git/R-source/PlusLotto.R", 
    echo = FALSE)
## Warning: package 'forecast' was built under R version 2.15.2
## Loading required package: parallel
## Loading required package: tseries
## Loading required package: quadprog
## Loading required package: zoo
## Attaching package: 'zoo'
## The following object(s) are masked from 'package:base':
## 
## as.Date, as.Date.numeric
## Loading required package: fracdiff
## Loading required package: Rcpp
## Loading required package: RcppArmadillo
## This is forecast 3.25
## Loading required package: R.oo
## Loading required package: R.methodsS3
## R.methodsS3 v1.4.2 (2012-06-22) successfully loaded. See ?R.methodsS3 for
## help.
## R.oo v1.10.1 (2012-10-16) successfully loaded. See ?R.oo for help.
## Attaching package: 'R.oo'
## The following object(s) are masked from 'package:methods':
## 
## getClasses, getMethods
## The following object(s) are masked from 'package:base':
## 
## attach, detach, gc, load, save
## R.utils v1.16.2 (2012-09-12) successfully loaded. See ?R.utils for help.
## Attaching package: 'R.utils'
## The following object(s) are masked from 'package:utils':
## 
## timestamp
## The following object(s) are masked from 'package:base':
## 
## cat, commandArgs, getOption, inherits, isOpen, lapply, parse, warnings
## Attaching package: 'gtools'
## The following object(s) are masked from 'package:R.utils':
## 
## capture

PART ONE (1): What are the latest Lotto results from Tatts.com and SingaporePools.com.sg?

LottoUpdate()
## [1] "The powerball file is the latest."
## [1] "Updated 1 result(s) for ozlotto file."
## [1] "The satlotto file is the latest."
## [1] "The wedlotto file is the latest."
## [1] "The toto file is the latest."
## [1] "The 4d file is the latest."
LottoResult()
## [1] "POWERBALL"
##  Draw No Draw Date Number Num Num Num Num Powerball
##      859 2012/11/1     25  28   6  16  12        10
## [1] "OZLOTTO"
##  Draw No Draw Date Number Num Num Num Num Num Num Supplement Supp
##      977 2012/11/6     29  43   8   7  15   2  13         21   20
## [1] "SATLOTTO"
##  Draw No Draw Date Number Num Num Num Num Num Supplement Supp
##     3265 2012/11/3     31  20  12  38  43   7         25    6
## [1] "WEDLOTTO"
##  Draw No  Draw Date Number Num Num Num Num Num Supplement Supp
##     3264 2012/10/31      7  36  42  38  43  27         13   19
## [1] "TOTO"
##  Draw No  Draw Date Number Num Num Num Num Num Additional
##     2794 2012/11/05      4   9  13  17  20  29         40
## [1] "4D"
##  Draw No  Draw Date First Prize  2nd  3rd Starter  Sta  Sta  Sta  Sta  Sta
##     3399 2012/11/04        7490 0962 1636    0930 1348 2327 5090 5833 1176
##   Sta  Sta  Sta  Sta
##  1509 2359 5488 5924
##  Consolation  Con  Con  Con  Con  Con  Con  Con  Con  Con
##         0196 1542 2778 3283 8865 0866 1921 2853 5420 9314

PART TWO (2): Could the computer generate Lotto numbers for the next draw?

LottoStandard()
## [1] "POWERBALL"
##       [,1] [,2] [,3] [,4] [,5] [,6]
##  [1,]   19   16   39   29    9   11
##  [2,]    9    5   30   22    7    2
##  [3,]   19   25   37   22   10   13
##  [4,]   30   31   27   15   17    4
##  [5,]   44    7   12   18    4    9
##  [6,]    3    1    4   42    9   15
##  [7,]   27   25   12    7   15    5
##  [8,]   20   33   11    4    5    9
##  [9,]   43   33    5   35    6    8
## [10,]   14   29    2    9   13   12
## [11,]   23   24   37   18   15    3
## [12,]   29   38   26    5   11    8
## [1] "OZLOTTO"
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7]
##  [1,]   41   15   14   25    7   12    2
##  [2,]   32   42   18   10   40   23    6
##  [3,]   20    6    7   18   15   25   22
##  [4,]   34    6   20    7   24   25   11
##  [5,]   42   27    9   18   38   32   11
##  [6,]   25   31   11   34   15   33    9
##  [7,]   43   37   16    9   11   18   15
##  [8,]   44   40   10   30   21   43    6
##  [9,]   26   27    6   11    3   31   15
## [10,]   33   20    6   40   42   35   12
## [11,]   29   43   19   16    3   10   11
## [12,]   28   15    8   10    4   33    3
## [1] "SATLOTTO"
##       [,1] [,2] [,3] [,4] [,5] [,6]
##  [1,]   29    2   12   39   40   15
##  [2,]   41    3    4   17   43    7
##  [3,]   43   21   15   14   34    3
##  [4,]   34    5   17   35   39    9
##  [5,]   28   14   12   39   40    5
##  [6,]   19   21    5   23   32   14
##  [7,]   42    2   10   44   43    9
##  [8,]   42   21    3   15   36    8
##  [9,]   19   20   13   17   37    2
## [10,]   41   11   16   20   35   15
## [11,]   21   14   16   15   42   17
## [12,]   24   28    8   30   35    9
## [1] "WEDLOTTO"
##       [,1] [,2] [,3] [,4] [,5] [,6]
##  [1,]    2   44   31   42   21   26
##  [2,]    6   25   27   30   14   10
##  [3,]   10   37   26   35   31    4
##  [4,]    6   21   32   14   19    2
##  [5,]    3   35   41    8   20   24
##  [6,]    6   22   33   41   32   16
##  [7,]    6   33   30   21   24   17
##  [8,]    3   41   32   17   21   28
##  [9,]    5   29   31   22   36    4
## [10,]    8   19   26   17    9   28
## [11,]    3   32   45   33   13    5
## [12,]   10   37   40   44   16   29
## [1] "TOTO"
##       [,1] [,2] [,3] [,4] [,5] [,6] [,7]
##  [1,]    4   17    5    8   31   29   13
##  [2,]   19    5    4    8   16   30   28
##  [3,]    9    8    2   26   32   19   35
##  [4,]   21   17   23   10   18   31   34
##  [5,]   10    9    1   28   14   23   37
##  [6,]    4   30   29   21   28   32    8
##  [7,]   10   23   18   19   28   34   30
##  [8,]   18    6    5   28   13   31   40
##  [9,]    8   28   11    7   31   30   42
## [10,]    7    9    5   27   15   39   31
## [11,]   22   21    2   12   30   19   45
## [12,]    9   11   20    8   34   18   13
## [1] "4D"
##  [1] "1748" "1573" "1677" "2314" "1988" "2262" "0455" "0912" "0309" "1749"
## [11] "1608" "1244"

PART THREE (3): What is the power of chance for the next draw?

This part answers a simple question: Has the odds increased favorably with the computer-drawn Lotto numbers?

LottoArimaSummary()
##       lotto power
## 1 powerball   7.6
## 2   ozlotto   4.1
## 3  satlotto  37.9
## 4  wedlotto  11.6
## 5      toto  16.1
## 6        4d   4.2

PART FOUR (4): Could we generate our own Lotto numbers for the next draw?

This part answers a simple question: Can we pick our own Lotto numbers from a confidence interval?

LottoArimaConf("powerball")
##   lower upper
## 1     3    45
## 2     1    39
## 3     1    45
## 4     1    45
## 5     1    17
## 6     1    15
## 7    14   137
LottoArimaConf("ozlotto")
##   lower upper
## 1    18    45
## 2     2    45
## 3     1    25
## 4     1    41
## 5     1    45
## 6     1    45
## 7     1    22
## 8    67   195
LottoArimaConf("satlotto")
##   lower upper
## 1    15    45
## 2     1    30
## 3     1    18
## 4    13    45
## 5    32    45
## 6     1    20
## 7    67   190
LottoArimaConf("wedlotto")
##   lower upper
## 1     1    13
## 2    19    45
## 3    25    45
## 4     1    45
## 5     8    45
## 6     1    40
## 7    91   211
LottoArimaConf("toto")
##   lower upper
## 1     3    24
## 2     3    30
## 3     1    29
## 4     6    35
## 5    10    38
## 6    18    41
## 7     8    45
## 8    87   219
LottoArimaConf("4d")
##   lower upper
## 1     0     2
## 2     2     9
## 3     0     9
## 4     0     9
## 5     4    26
#
# |------------------------------------------------------------------------------------------|
# | E N D O F S C R I P T |
# |------------------------------------------------------------------------------------------|