Professional Documents
Culture Documents
116
Introduc)on to Data Analysis in Earth Science
Midterm exam
Part 1: take home available NOW on the class website:
hVps://eee.uci.edu/15f/42120/midterm
DUE: November 5th, 2:00 pm (do your own work)
I highly recommend starZng to work on the midterm early
Midterm EvaluaZon
Open unZl next lecture
What should be improved ?
What can I do to help you learn or is there something
that isnt working ?
Are the quick reviews useful ?
Are the lab useful ? Should they be longer ?
Do you want more MATLAB, more stats, or this is a good
balance ?
Todays lecture
1. Lecture 5 quick review
2. Lecture 6 Hypothesis tesZng
Sampling DistribuZon of the sample mean
Central Limit Theorem (CLT)
Condence intervals
Hypothesis TesZng
t-test (Comparing means)
2-test (Goodness of t)
Lecture 5 - review
Popula'on: the actual properZes of the real world
Sample: set of values imperfectly represenZng the
populaZon
Parameters: refer to the popula)on (e.g., and )
x
Lecture 5 - review
Sample visualizaZon
Frequency Table
CumulaZve Frequency
Histogram
Dispersion:
Range (max min)
Standard deviaZon (average distance to mean)
Variance (square of Std Dev)
Shape:
Skewness (posiZve: tail to the right, negaZve: tail to the lem)
x2
f (x)dx
x1
Given p0, nd x0
>> x0 = norminv(p0,mu,sigma);
Z-distribuZon
>> p0 = normcdf(x0);
>> x0 = norminv(p0);
t-distribuZon
>> p0 = tcdf(x0,V);
>> x0 = tinv(p0,V);
2-distribuZon
>> p0 = chi2cdf(x0,V);
>> x0 = chi2inv(p0,V);
p0 = P( x < x0)
e.g.: 0.88 = P(x < 1.17)
i>Clicker quesZon
ESS 116 grades follow a Normal distribuZon of mean
800 with a standard deviaZon of 100. What is the
probability of having a grade below 500?
A.
B.
C.
D.
1 normcdf(500,800,100);
1 norminv(500,800,100);
normcdf(500,800,100);
norminv(500,800,100);
Sampling distribuZons
Sampling distribuZons
For one populaZon, results will vary from sample to
sample
How much do we except these results to vary from
sample to sample?
Sampling distribu'on: distribuZon associated to
samples rather than individual values from a populaZon
Example: Sampling distribu)on of the sample mean
Graph of all possible values of the sample mean and
how omen they occur
The mean of the populaZon of all possible sample
means is the same as the mean of the enZre populaZon
Sampling distribuZon
PopulaZon distribuZon
i>Clicker quesZon
What would happen to the standard deviation of the sample mean (right) if we
increase the number of rolls for all sample (n=20 or n=100) ?
A.
B.
C.
D.
=p
Sample size
Sampling
distribuZon
of the
sample mean
X =
Example
Example
Population distribution
= 0.7L
< 2.2)
= 1 P( x
= 2L
Sampling distribution of the Sample mean
= 1 normcdf(2.2,2,0.7/sqrt(50))
= 0.0217
=p
0.7
=p
50
N
P (
x > 2.2L)
X = = 2L
Condence Interval
X
T x
T
= P( < < )
= 1-
Follows a z-distribution !
Example n>30
You sample 36 apples from your farms harvest of over
200,000 apples. The mean weight of the sample is 112
grams (with s = 40 grams).
What is the probability that the mean weight of the
200,000 apples is within 100 and 124 grams?
Example n>30
Population distribution
) = P( x
within 12 of )
P( within 12 of x
= P( x
within 12 of X )
= P(
12
Z=
<
+12
= normcdf(12/(40/6))
- normcdf(-12/(40/6))
Sampling distribution of
the Sample mean Normalized
<
= 0.9281
X
ps
n
12/
Example n<30
7 paZents blood pressures have been measured amer
having been given a new drug for 3 months. They had
blood pressure increases of 1.5 2.9 0.9 3.9 3.2 2.1 and 1.9
Construct the 95% Condence Interval (CI) for the true
expected blood pressure increase for all paZents in a
populaZon.
Example n<30
Population distribution
x
= 2.3429
s = 1.0422
Z=
95%
z = Znv(0.975,7-1)
= +2.4469
x
p = 2.4469
s/ n
X
ps
n
s
x = 2.4469 p
n
x = 0.9639
2.5%
- z
2.5%
Hypothesis TesZng
IntroducZon
You read that, on average, a volcanic erupZon lasts 7 weeks (=7).
But we suspect that this number is wrong and should higher (>7).
How can we prove for a given level of signicance (=0.05)?
x
s
=p 'p
n
n
> 7.2)
P(x
< 7.2)
= 1 P( x
= 1 normcdf(7.2,7,1/10)
= 0.0228 <
=7
x
= 7.2
=7
s
=p 'p
n
n
x
= 7.2
> 7.2)
P(x
p-value
< 7.2)
= 1 P( x
= 1 normcdf(7.2,7,1/10)
= 0.0228 <
Hypothesis tesZng
The classical way to make staZsZcal comparisons is to prepare
a statement about a fact for which it is possible to calculate
its probability of occurrence.
This statement is the null hypothesis and its counterpart is
the alterna've hypothesis.
The null hypothesis is tradiZonally wriVen as H0 and the
alternaZve hypothesis as H1.
A staZsZcal test measures the experimental strength of
evidence against the null hypothesis.
Curiously, depending on the risks at stake, the null hypothesis
is omen the reverse of what the experimenter actually
believes for tacZcal reasons.
Examples of Hypotheses
Let 1 and 2 be the means of 2 samples
We want to invesZgate the likelihood that their means
are the same:
Null Hypothesis:
H0: 1 = 2
AlternaZve Hypothesis : H1: 1 2
The AlternaZve Hypothesis could also be: H1: 1 > 2
The rst example of H1 is said to be two-sided or twotailed (includes both 1 > 2 and 1 < 2)
The second is said to be one-sided or one-tailed.
The number of sides has implicaZons on how to
formulate the test
Possible outcomes
H0 is correct
H0 is incorrect
H0 is accepted
Correct decision
Probability: 1-
Type II error
(missed detec)on)
Probability:
H0 is rejected
Type I error
(false alarm)
Probability:
Correct decision
Probability: 1-
Importance of choosing H0
SelecZng H0 has consequences on decision making
Customarily, tests operate on the lem column of the conZngency
table and the harder to analyze right column remains unchecked
Consider a jury trial:
H0 : not guilty
True
False
False
Importance of choosing H0
SelecZng H0 has consequences on decision making
Customarily, tests operate on the lem column of the conZngency
table and the harder to analyze right column remains unchecked
Consider environmental remedial acZon:
H0 : Site is clean
True
False
H0 : Site is contaminated
True
Test Accept Correct
acZon Reject Wrong
False
StaZsZc
A key step in the feasibility of being able to run a test is the ability of
nding an analyZcal expression for a staZsZc such that:
It is sensiZve to all parameters involved in the null hypothesis
It has an associated probability distribuZon
p-value: the probability that the staZsZc takes values beyond the
value calculated using the data while H0 is sZll true. Hence:
If p-value > (level of signicance), H0 is accepted
The lower the p-value, the stronger is the evidence provided by
the data against the null hypothesis.
The p-value allows to convert the staZsZc to probability units
ParZZon
The level of signicance is employed to parZZon the range of
possible values of the staZsZc into two classes:
One interval, usually the longest one (in green), contains those
values that, although not necessarily saZsfying the null
hypothesis exactly, are quite possibly the result of random
variaZon. If the staZsZc falls in this interval, H0 is accepted
accept
reject
accept
reject
Sampling distribuZon
The sampling distribuZon of a staZsZc is the distribuZon
of values taken by the staZsZc for all possible random
samples of the same size from the same populaZon.
Examples of such sampling distribuZons are:
Standard normal and the t-distribuZons for the
comparison of two means
The F-distribuZon for the comparison of two variances
The 2-distribuZon for the comparison of two
distribuZons
TesZng Procedure
1. Select the null hypothesis H0 and
the alternaZve hypothesis H1.
2. Choose the appropriate staZsZc
3. Set the level of signicance
4. Evaluate the staZsZc for the case
of interest, zs.
5. Use the distribuZon for the staZsZc in combinaZon with the level
of signicance to dene the acceptance and rejecZon intervals.
Find out either the corresponding:
p-value of the staZsZc in the probability space, or
level of signicance in the staZsZc space, z.
Dierence in mean
Is the dierence in mean between these 2 groups
systemaZc, or just due to chance?
Dierence in mean
Is the dierence in mean between these 2 groups
systemaZc, or just due to chance?
Dierence in mean
Is the dierence in mean between these 2 groups
systemaZc, or just due to chance?
Dierence in mean
Factors aecZng our condence in the answer:
Natural variability (standard deviaZon)
Sample sizes (n)
Students t test
Null-Hypothesis:
(H0): 1 = 2
AlternaFve Hypothesis: (H1): 1 2
PopulaZon means are staZsZcally dierent.
xd , sd )
We look at the dierences between all n pairs: (
tstat
x
d
p
=
sd / n
= n - 1
x
d
p
=
sd / n
If tstat is small:
The dierence between groups is smaller than the normal
variability within the sample
Therefore: the means of the 2 samples are not signicantly
dierent from each other
0.35
0.3
Density
0.25
There is only a 5%
probability of
nding
t values higher
than this value
purely by chance...
There is only a 5%
probability of
nding
t values higher
than this value
purely by chance...
There is
a 90% chance
of nding
t values in this
range by chance
0.2
0.15
0.1
0.05
0
-4
-3
-2
-1
Critical Value
Summary
How to conduct a t-test?
1. Decide upon a level of signicance .
e.g. 99% and 95% are typical ( = 0.01 or 0.05)
2. From this, decide if one-tailed or two-tailed and
use MATLABS tinv command to nd tcrit
3. Compute tstat from your sample
4. Compare tstat and tcrit
If |tstat| > tcrit: the dierence is signicant (theres likely
an actual dierence between the to means)
else: the dierence is not signicant
Example
We are interested in ocean acidicaZon. We measure the pH of
ocean water at the pier of Newport Beach at two dierent dates:
In 1994: 8.03, 8.08, 7.99, 8.00, 7.93, 7.98
In 2004: 7.99, 8.02, 7.92, 7.94, 8.01, 7.93
From our two sample, we have:
In 1994: m1 = 8.0017 and s1 = 0.0504
In 2004: m2 = 7.9683 and s2 = 0.0406
Does the dierence between the two means show a signicant
decrease or is it likely caused just by chance?
Example
1. Choose a level of signicance = 0.1 (CI 90%)
2. This is a one tailed test (H1: m2 < m1)
2
-test Goodness of t
2-test Goodness of t
We want to compare an observed frequency
distribuZon to a theoreZcal distribuZon.
Ex: we want to show that the yearly averaged rainfall in
Irvine follows a normal distribuZon
Ex: we want to make sure that a dice is not loaded
2 staZsZc
We decompose the number of observaZons (n) over
k intervals (or bins, or classes)
k must saZsfy n/k 5
k 10
So n 50
k
X
(Oi
i=1
Ei )
Ei
2 staZsZc
2stat measures the mismatch between the Expected
and the Observed distribuZons
2stat = 0 perfect t
2stat large: poor t
ConducZng a 2 test
1. Formulate a null and alternaZve hypothesis:
H0: The data are consistent with a specied distribuZon
H1: The data are not consistent with a specied distribuZon
i=1
Ei
Example
Is our dice loaded? Compare to a uniform distribuZon
Value
Observed freq.
Expected freq.
(O-E)^2/E
16
10
3.6
10
2.5
10
0.1
10
0.9
10
1.6
17
10
4.9
Total
60
60
13.6
For alpha = 0.02:
chi2crit = chi2inv(1-0.1,6-1) =13.3882
The die is loaded (98% condence interval)
Next Week