Book Image

Simulation for Data Science with R

By : Matthias Templ
Book Image

Simulation for Data Science with R

By: Matthias Templ

Overview of this book

Data Science with R aims to teach you how to begin performing data science tasks by taking advantage of Rs powerful ecosystem of packages. R being the most widely used programming language when used with data science can be a powerful combination to solve complexities involved with varied data sets in the real world. The book will provide a computational and methodological framework for statistical simulation to the users. Through this book, you will get in grips with the software environment R. After getting to know the background of popular methods in the area of computational statistics, you will see some applications in R to better understand the methods as well as gaining experience of working with real-world data and real-world problems. This book helps uncover the large-scale patterns in complex systems where interdependencies and variation are critical. An effective simulation is driven by data generating processes that accurately reflect real physical populations. You will learn how to plan and structure a simulation project to aid in the decision-making process as well as the presentation of results. By the end of this book, you reader will get in touch with the software environment R. After getting background on popular methods in the area, you will see applications in R to better understand the methods as well as to gain experience when working on real-world data and real-world problems.
Table of Contents (18 chapters)
Simulation for Data Science with R
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Winning the lottery


Let us look at the lottery numbers from Britain from the last seven months. With some tricks we can grep them from the Internet:

library("RCurl")
URL <- "https://www.national-lottery.co.uk/results/euromillions/draw-history/csv"
lotto <- read.csv(textConnection(getURL(URL)))

The structure of these data sets is as follows:

str(lotto)
## 'data.frame':    52 obs. of  10 variables:
##  $ DrawDate            : Factor w/ 52 levels "01-Apr-2016",..: 24 18 12 6 49 45 37 33 25 21 ...
##  $ Ball.1              : int  7 2 32 8 4 10 17 11 13 1 ...
##  $ Ball.2              : int  15 26 34 23 5 17 26 14 14 5 ...
##  $ Ball.3              : int  28 27 40 24 25 31 32 15 32 9 ...
##  $ Ball.4              : int  31 40 45 34 28 32 34 27 37 22 ...
##  $ Ball.5              : int  42 49 48 38 43 42 43 44 48 38 ...
##  $ Lucky.Star.1        : int  10 5 1 3 6 2 2 2 1 2 ...
##  $ Lucky.Star.2        : int  11 10 10 7 11 5 10 7 7 10 ...
##  $ UK.Millionaire.Maker: Factor w/ 52 levels ...