Module01 Notes
Module01 Notes
0.1 Motivation
Introduction
The term “Data Science” has existed for about a decade. In the early
days, many people working with data called themselves data scien-
tists, which lead to confusion about what data science is.
The world collects more and more data every day and in every field.
• Biotechnology
– Mapping genes and relating them to disease
– Understanding metabolites and there relationship to the envi-
ronment
• Finance
– Credit Risk management
– Customer Segmentation
– Predictive Modelling
– Fraud detection
• Energy
– Forecasting demand
• Government
– Tax Evasion
– Security
– Health care
3
• Retail
– Recommendations
– Loyalty programs
– Supply Chain
• Telecommunications
– Customer behaviour modelling
– Network Optimisation
– Social Media and Viral campaigns
– Churn
This Unit
Unit Philosophy
• [Link]
• [Link]
Topics
4
Lecture Topic
1 Introduction and “Are the digits of pi random?”
2 Counting Eels and Iraqi Refugees
3 Maternal smoking and birth weight
4 Maternal Smoking and Birth Weight (cont)
5 Mapping disease
6 Observation or Experiment?
7 Do taller people earn more?
8 No really, do taller people earn more?
9 Do redheads have a lower pain threshold?
10 What is Normal anyway?
11 Normality as opposed to being deviant, eccentric or unusual
12 When it all goes wrong.
Teaching Team
Unit Coordinator:
The learning guide is found in vUWS > 301108 > Unit Information
5
Assessment
• You must obtain at least 50 of the 100 marks to pass this subject and must take at least 12 marks from
the final exam.
Text Book
There is no text book for this unit, all of the material will be provided
in the lecture notes and lab notes.
0.3 R
Introducing R
What is R?
Pros Its free and open source. It has a large active communinity
of contributors, meaning that many classical and modern statistical
methods are available for it. It has the publication quality graphics. It
extendable.
R Resources
Pi
Pi
3.141592653589793238462643383279502884197169399375105820974944592307816406286208
99862803482534211706798214808651328230664709384460955058223172535940812848111745
02841027019385211055596446229489549303819644288109756659334461284756482337867831
65271201909145648566923460348610454326648213393607260249141273724587006606315588
17488152092096282925409171536436789259036001133053054882046652138414695194151160
94330572703657595919530921861173819326117931051185480744623799627495673518857527
248912279381830119492
1/9 =
0.111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
1111111111111111111111
1/81 - 10/89999999991 =
0.012345678901234567890123456789012345678901234567890123456789012345678901234567
89012345678901234567890123456789012345678901234567890123456789012345678901234567
89012345678901234567890123456789012345678901234567890123456789012345678901234567
89012345678901234567890123456789012345678901234567890123456789012345678901234567
89012345678901234567890123456789012345678901234567890123456789012345678901234567
89012345678901234567890123456789012345678901234567890123456789012345678901234567
89012345678901234567890
9
e=
2.718281828459045235360287471352662497757247093699959574966967627724076630353547
59457138217852516642742746639193200305992181741359662904357290033429526059563073
81323286279434907632338298807531952510190115738341879307021540891499348841675092
44761460668082264800168477411853742345442437107539077744992069551702761838606261
33138458300075204493382656029760673711320070932870912744374704723069697720931014
16928368190255151086574637721112523897844250569536967707854499699679468644549059
879316368892300987931
It seems that random in this context is not all that well defined.
For this type of example there are generally two aspects to ran-
dom.
1. The digits should occur the same proportion of the time (unifor-
mity)
2. They should not be predictable, given part of the se-
quence/expansion we can’t predict the next digit.
0 1 2 3 4 5 6 7 8 9
45 59 54 50 53 50 48 36 53 52
Since there are ten possible digits and we looked at the first 500 we
expect to see 50 of each if they are uniform. . .
0 1 2 3 4 5 6 7 8 9
45 59 54 50 53 50 48 36 53 52
Random Digits.
In the following table, there are the counts of truly 1 random dig- 1
As generated by a computer at least
its. Each row is one replication of 500 random digits. What do you
notice?
0 1 2 3 4 5 6 7 8 9
48 50 48 57 51 60 42 45 61 38
60 52 40 47 42 52 51 55 55 46
41 47 50 47 38 62 63 52 48 52
58 43 45 47 64 51 52 45 54 41
57 45 59 37 53 55 49 48 47 50
52 63 47 58 42 46 49 41 52 50
55 58 49 50 41 48 43 45 54 57
50 56 48 47 54 44 48 53 55 45
57 55 44 38 52 48 53 51 52 50
44 54 49 52 55 47 45 52 53 49
11
Random Digits.
There are quite a few differences from the expected count of 50. In
fact, the largest is 64 and the smallest is 37
Random Digits
It is a bit difficult to see the differences in the table from the expected
count of 50. So we can subtract it. Remember each row is different set
of 500 digits.
0 1 2 3 4 5 6 7 8 9
-2 0 -2 7 1 10 -8 -5 11 -12
10 2 -10 -3 -8 2 1 5 5 -4
-9 -3 0 -3 -12 12 13 2 -2 2
8 -7 -5 -3 14 1 2 -5 4 -9
7 -5 9 -13 3 5 -1 -2 -3 0
2 13 -3 8 -8 -4 -1 -9 2 0
5 8 -1 0 -9 -2 -7 -5 4 7
0 6 -2 -3 4 -6 -2 3 5 -5
7 5 -6 -12 2 -2 3 1 2 0
-6 4 -1 2 5 -3 -5 2 3 -1
Random Digits
Some of these differences are negative and some are positive, but
they are all distances to the expected count. We can get rid of the sign
by squaring.
0 1 2 3 4 5 6 7 8 9 Total
4 0 4 49 1 100 64 25 121 144 512
100 4 100 9 64 4 1 25 25 16 348
81 9 0 9 144 144 169 4 4 4 568
12
0 1 2 3 4 5 6 7 8 9 Total
64 49 25 9 196 1 4 25 16 81 470
49 25 81 169 9 25 1 4 9 0 372
4 169 9 64 64 16 1 81 4 0 412
25 64 1 0 81 4 49 25 16 49 314
0 36 4 9 16 36 4 9 25 25 164
49 25 36 144 4 4 9 1 4 0 276
36 16 1 4 25 9 25 4 9 1 130
The total column is just the sum across each row of the squared
values.
Random Digits
512 348 568 470 372 412 314 164 276 130
If anything this number is on the small side. That is, counts of the
digits of π seems to be similar to that for uniform random digits.
1/81
0.012345679012345679012345679012345679012345679012345679012345679012345679012345
67901234567901234567901234567901234567901234567901234567901234567901234567901234
56790123456790123456790123456790123456790123456790123456790123456790123456790123
45679012345679012345679012345679012345679012345679012345679012345679012345679012
34567901234567901234567901234567901234567901234567901234567901234567901234567901
23456790123456790123456790123456790123456790123456790123456790123456790123456790
12345679012345679012346
0 1 2 3 4 5 6 7 8 9
56 56 56 56 56 55 55 55 0 55
1/81
In fact for 1/81 this total is around 2.5 times the largest value ob-
tained when looking at random uniform digits (at least for 10 sets)
512 348 568 470 372 412 314 164 276 130
So for 1/81 the total squared difference is still larger than largest
from 10000 sets of random digits. But for π, its well under.
Summary
Postscript