SlideShare a Scribd company logo
1 of 41
Sampling and Hypothesis Testing(I)
in MATLAB
Kajal Rai
kajalrai.pu@gmail.com
Contents:
• Sampling
• Hypothesis Test
• Types of parametric test
• One sample t-test
• Paired t-test
• Tailed t-test
• Two sample t-test
• z-test
• F-test
• Difference between t-test, z-test and F-test
Sampling:
• Sampling is the technique to be used in selecting the
items for the sample from the population.
• Simple Random Sampling: In which each and every
unit of the population has an equal opportunity of
being selected in the sample.
• Can be done with or without replacement.
• If done with replacement, then each item has a
probability of 1/N of being drawn at each selection.
• If done without replacement, then the first item has a
probability of 1/N, second item has 1/(N-1) and so on
of being drawn.
Random Sampling in MATLAB
• y = randsample(n,k) returns a vector of k
sample of values sampled uniformly at
random, without replacement, from the
integers 1 to n.
• y = randsample(population,k) returns a vector
of k values sampled uniformly at random,
without replacement, from the values in the
vector population.
Random Sampling in MATLAB cntd…
• y = randsample(n,k,replacement) or
y = randsample(population,k,replacement)
returns a sample taken with replacement
if replacement is true, or without replacement
if replacement is false. By default it is false.
Random Sampling in MATLAB cntd…
• y = randsample(n,k,true,w) or
y = randsample(population,k,true,w) returns a
weighted sample taken with replacement,
using a vector of positive weights w, whose
length is n. The probability that the integer i is
selected for an entry of y is w(i)/sum(w).
Where, w is a vector of probabilities.
• randsample does not support weighted
sampling without replacement.
Generate a random sequence of the characters A, C, G,
and T, with replacement, according to the specified
probabilities.
Hypothesis Tests:
• A hypothesis test is a procedure for
determining if an assertion about a
characteristic of a population is correct.
• In hypothesis testing, the goal is to see if there
is sufficient statistical evidence to accept a
presumed null hypothesis or to reject
the alternative hypothesis[1].
• The null hypothesis is usually
denoted H0 while the alternative hypothesis is
usually denoted H1.
Types of parametric test:
• One sample t-test: The one-sample t-test is used when we want to know
whether our sample comes from a particular population but we do not have
full population information available to us. Used when we don't know the
variance.
• Paired t-test: A paired t-test looks at the difference between paired values
in two samples, takes into account the variation of values within each
sample, and produces a single number known as a t-value.
• Two sample t-test:To compare responses from two groups. These two
groups can come from different experimental treatments, or different
"populations".
• z-test: It is an appropriate parametric statistical procedure when there is
one sample that is being compared to a population with a known mean and
standard deviation.
• F-test: The F-test is designed to test if two population variances are equal.
One sample t-test:
• [h,p,ci,stat] = ttest(X,M) performs a t-test of the hypothesis
that the data in X come from a distribution with mean M.
• CI returns a 100*(1-ALPHA)% confidence interval for the
true mean of X.
• STATS returns a structure with the following fields:
• 'tstat' -- the value of the test statistic
• 'df' -- the degrees of freedom of the test
• 'sd' -- the estimated population standard deviation.
One sample t-test example:
• Ex: The specimen of copper wires drawn form a
large lot have the following breaking strength
(in kg. weight):
• 578, 572, 570, 568, 572, 578, 570, 572, 596, 544
• Test (using Student’s t-statistic)whether the
mean breaking strength of the lot may be taken
to be 578 kg. weight (Test at 5 per cent level of
significance).
t-test with own significance level:
• [h,p,ci,stat] = TTEST(...,ALPHA) performs the test at the significance level
(100*ALPHA)%. ALPHA must be a scalar.
Paired t-test:
• A paired t-test looks at the difference
between paired values in two samples, takes
into account the variation of values within
each sample, and produces a single number
known as a t-value.
Paired t-test in MATLAB:
• H = TTEST(X,Y) performs a paired T-test of
the hypothesis that two matched samples, in
the vectors X and Y, come from distributions
with equal means. The difference X-Y is
assumed to come from a normal distribution
with unknown variance.
• X and Y must have the same length.
Example: Paired t-test
• Memory capacity of 9 students was tested
before and after training. State at 5 percent
level of significance whether the training was
effective from the following scores:
• Before:10,15,9,3,7,12,16,17,4
• After:12,17,8,5,6,11,18,20,3
• Take the score before training as X and the
score after training as Y and then taking the
null hypothesis that the mean of difference is
zero
we accept H0 and conclude that the difference in score before and after training is insignificant
i.e., it is only due to sampling fluctuations. Hence we can infer that the training was not
effective.
Tailed t-test:
• A one- or two-tailed t-test is determined by
whether the total area of α is placed in one tail
or divided equally between the two tails.
• The one-tailed t-test is performed if the results
are interesting only if they turn out in a
particular direction.
• The two-tailed t-test is performed if the results
would be interesting in either direction.
ααα
One-Tailed t-Test:
• There are two different one-tailed t-tests, one for each
tail.
• In a one-tailed t-test, all the area associated with α is
placed in either one tail or the other. Selection of the
tail depends upon which direction t would be (+ or -)
if the results of the experiment came out as expected.
• The selection of the tail must be made before the
experiment is conducted and analyzed.
• Test to see whether one mean was higher than the
other.
One-tailed t-test in the positive direction
The value tcrit would be positive. For example when α is set to .05
with ten degrees of freedom (df=10), tcrit would be equal to +1.812.
One-tailed t-test in the negative direction
The value tcrit would be negative. For example, when αis set to .05
with ten degrees of freedom (df=10), tcrit would be equal to -1.812.
Two-Tailed t-Test:
• A two-tailed t-test divides αin half, placing half in the each tail. The null hypothesis
in this case is a particular value, and there are two alternative hypotheses, one
positive and one negative. The critical value of t, tcrit, is written with both a plus and
minus sign (± ). For example, the critical value of t when there are ten degrees of
freedom (df=10) and α is set to .05, is tcrit= ± 2.228.
• We would use a two-tailed test to see if two means are different from each other (ie
from different populations), or from the same population.
Tailed t-test in MATLAB
• H = TTEST(...,TAIL) performs the test against
the alternative hypothesis specified by TAIL:
• 'both' -- "mean is M" (two-tailed test)
• 'right' -- "mean is greater than M" (right-tailed
test)
• 'left' -- "mean is less than M" (left-tailed test)
One tailed t-test in MATLAB
Two-tailed test in MATLAB
Two sample t-test
• H = TTEST2(X,Y) performs a T-test of the
hypothesis that two independent samples, in the
vectors X and Y, come from distributions with equal
means, and returns the result of the test in H.
• H=0 indicates that the null hypothesis ("means are
equal") cannot be rejected at the 5% significance
level. H=1 indicates that the null hypothesis can be
rejected at the 5% level.
• The data are assumed to come from normal
distributions with unknown, but equal, variances.
• X and Y can have different lengths.
Example:
• A group of seven-week old chickens reared on a high protein
diet weight 12, 15, 11, 16, 14, 14, and 16, a second group of
five chickens, similarly treated except that they receive a low
protein diet, weight 8, 10, 14, 10 and 13. Testing at 5 percent
level whether there is significant evidence that additional
protein has increased the weight of the chickens. Using
assumed mean = 10 for the sample of 7 and assumed mean = 8
for the sample of 5 chickens in our calculations.
• Taking the null hypothesis that additional protein has not
increased the weight of the chickens
Two sample t-test in MATLAB
we reject H0 and conclude that additional protein has increased the weight of chickens, at 5
per cent level of significance.
Two sample t-test in MATLAB cntd…
• H = TTEST2(X,Y,ALPHA,TAIL,VARTYPE) allows
you to specify the type of test. When VARTYPE is
'equal', TTEST2 performs the default test assuming
equal variances.
• When VARTYPE is 'unequal', TTEST2 performs the
test assuming that the two samples come from normal
distributions with unknown and unequal variances.
This is known as the Behrens-Fisher problem.
z-test in MATLAB
A z-test is used for testing the mean of a population or
comparing the means of two populations, with large (n ≥ 30)
samples when we know the population standard deviation.
• H = ZTEST(X,M,SIGMA) performs a Z-test of the hypothesis
that the data in the vector X come from a distribution with
mean M, and returns the result of the test in H.
• H=0 indicates that the null hypothesis ("mean is M") cannot
be rejected at the 5% significance level. H=1 indicates that the
null hypothesis can be rejected at the 5% level.
• The data are assumed to come from a normal distribution with
standard deviation SIGMA.
Example:
• A dog food manufacturer, had created new Super Vitamin
Enriched Puppy Chow, specially designed for the active and
growing Doberman Pincer.
• The sample of 10 Doberman puppies are 27.5, 33.5, 36.8, 39.5,
40.5, 42.5, 40.0, 22.9, 39.8, 40.8 and fed them nothing but
with Super Vitamin Enriched Puppy Chow. When these dogs
reached adulthood, they weighed 39.7 kg on average (M) and
σ = 6.2 kg
• Did Puppy Chow make them grow especially big, test with a =
.05?
• H0: The puppy chow did make the dogs grow more than
normal.
• H1: The puppy chow did not make the dogs grow larger than
normal
We will accept H0 and conclude that the Super Vitamin Enriched Puppy Chow makes
Doberman Pincers grow significantly larger.
F-test:
• F-test is used to compare the variance of the
two-independent samples.
• This test is also used in the context of analysis
of variance (ANOVA) for judging the
significance of more than two sample means at
one and the same time.
• It is also used for judging the significance of
multiple correlation coefficients.
F-test in MATLAB
• H = vartest2(X,Y) performs an F test of the
hypothesis that two independent samples, in the
vectors X and Y, come from normal distributions
with the same variance, against the alternative that
they come from normal distributions with different
variances.
• The result is H=0 if the null hypothesis ("variances
are equal") cannot be rejected at the 5% significance
level, or H=1 if the null hypothesis can be rejected at
the 5% level.
• X and Y can have different lengths.
Example:
• Two random samples drawn from two normal
populations are:
• Sample1: 20 16 26 27 23 22 18 24 25 19
• Sample2: 27 33 42 35 32 34 38 28 41 43 30 37
• At 5% significance level.
• We take the null hypothesis that the two populations
from where the samples have been drawn have the
same variances
Since p value is more than 0.05 as such we accept the null hypothesis and conclude that
samples have been drawn from two populations having the same variances.
Difference between t-test, z-test and F-test:
t-test z-test F-test
A t-test is used for testing the
mean of one population
against a standard or
comparing the means of two
populations. And when you
do not know the populations’
standard deviation and when
you have a limited sample (n
< 30).
A z-test is used for testing the
mean of a population versus a
standard, or comparing the
means of two populations, with
large (n ≥ 30) samples when we
know the population standard
deviation.
It is also used for testing the
proportion of some characteristic
versus a standard proportion, or
comparing the proportions of
two populations.
An F-test is used to
compare 2 populations’
variances. The samples can
be any size. It is the basis of
ANOVA.
References:
• Kothari, C.R.,1985, Research Methodology- Methods and
Techniques, New Delhi, Wiley Eastern Limited.
• S.P.Gupta,Statistical Methods,eight revised edition 2009
• http://www.mathworks.in/help/stats/ztest.html#btriieq
• http://www.math.uah.edu/stat/hypothesis/Introduction.html
• http://www.mathworks.in/products/statistics/description7.html
• How to Do a T-Test in MATLAB
eHow http://www.ehow.com/how_12211819_ttest-
matlab.html#ixzz2WSQ6BN6o
THANK YOU

More Related Content

What's hot

How the blast work
How the blast workHow the blast work
How the blast workAtai Rabby
 
Dotplots for Bioinformatics
Dotplots for BioinformaticsDotplots for Bioinformatics
Dotplots for Bioinformaticsavrilcoghlan
 
The Method Of Maximum Likelihood
The Method Of Maximum LikelihoodThe Method Of Maximum Likelihood
The Method Of Maximum LikelihoodMax Chipulu
 
PCA and LDA in machine learning
PCA and LDA in machine learningPCA and LDA in machine learning
PCA and LDA in machine learningAkhilesh Joshi
 
Threading modeling methods
Threading modeling methodsThreading modeling methods
Threading modeling methodsratanvishwas
 
Applications of Single Cell Analysis
Applications of Single  Cell AnalysisApplications of Single  Cell Analysis
Applications of Single Cell AnalysisQIAGEN
 
Introduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorIntroduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorAmir Al-Ansary
 
DNA Methylation Data Analysis
DNA Methylation Data AnalysisDNA Methylation Data Analysis
DNA Methylation Data AnalysisYi-Feng Chang
 
Statistical significance of alignments
Statistical significance of alignmentsStatistical significance of alignments
Statistical significance of alignmentsavrilcoghlan
 
Flux balance analysis
Flux balance analysisFlux balance analysis
Flux balance analysisJyotiBishlay
 
An introduction to RNA-seq data analysis
An introduction to RNA-seq data analysisAn introduction to RNA-seq data analysis
An introduction to RNA-seq data analysisAGRF_Ltd
 
O.M.GSEA - An in-depth introduction to gene-set enrichment analysis
O.M.GSEA - An in-depth introduction to gene-set enrichment analysisO.M.GSEA - An in-depth introduction to gene-set enrichment analysis
O.M.GSEA - An in-depth introduction to gene-set enrichment analysisShana White
 
Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)Ram Narasimhan
 
EST Clustering.ppt
EST Clustering.pptEST Clustering.ppt
EST Clustering.pptMedhavi27
 

What's hot (20)

How the blast work
How the blast workHow the blast work
How the blast work
 
Dotplots for Bioinformatics
Dotplots for BioinformaticsDotplots for Bioinformatics
Dotplots for Bioinformatics
 
The Method Of Maximum Likelihood
The Method Of Maximum LikelihoodThe Method Of Maximum Likelihood
The Method Of Maximum Likelihood
 
PCA and LDA in machine learning
PCA and LDA in machine learningPCA and LDA in machine learning
PCA and LDA in machine learning
 
Threading modeling methods
Threading modeling methodsThreading modeling methods
Threading modeling methods
 
Applications of Single Cell Analysis
Applications of Single  Cell AnalysisApplications of Single  Cell Analysis
Applications of Single Cell Analysis
 
Introduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood EstimatorIntroduction to Maximum Likelihood Estimator
Introduction to Maximum Likelihood Estimator
 
Protein fold recognition and ab_initio modeling
Protein fold recognition and ab_initio modelingProtein fold recognition and ab_initio modeling
Protein fold recognition and ab_initio modeling
 
Chi square mahmoud
Chi square mahmoudChi square mahmoud
Chi square mahmoud
 
DNA Methylation Data Analysis
DNA Methylation Data AnalysisDNA Methylation Data Analysis
DNA Methylation Data Analysis
 
Statistical significance of alignments
Statistical significance of alignmentsStatistical significance of alignments
Statistical significance of alignments
 
Flux balance analysis
Flux balance analysisFlux balance analysis
Flux balance analysis
 
An introduction to RNA-seq data analysis
An introduction to RNA-seq data analysisAn introduction to RNA-seq data analysis
An introduction to RNA-seq data analysis
 
Rna seq pipeline
Rna seq pipelineRna seq pipeline
Rna seq pipeline
 
O.M.GSEA - An in-depth introduction to gene-set enrichment analysis
O.M.GSEA - An in-depth introduction to gene-set enrichment analysisO.M.GSEA - An in-depth introduction to gene-set enrichment analysis
O.M.GSEA - An in-depth introduction to gene-set enrichment analysis
 
Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)Data Manipulation Using R (& dplyr)
Data Manipulation Using R (& dplyr)
 
Sage
SageSage
Sage
 
Primer designing
Primer designingPrimer designing
Primer designing
 
Blast Algorithm
Blast AlgorithmBlast Algorithm
Blast Algorithm
 
EST Clustering.ppt
EST Clustering.pptEST Clustering.ppt
EST Clustering.ppt
 

Viewers also liked

Hypothesis testing examples on z test
Hypothesis testing examples on z testHypothesis testing examples on z test
Hypothesis testing examples on z testJags Jagdish
 
T test, independant sample, paired sample and anova
T test, independant sample, paired sample and anovaT test, independant sample, paired sample and anova
T test, independant sample, paired sample and anovaQasim Raza
 
Test of hypothesis
Test of hypothesisTest of hypothesis
Test of hypothesisvikramlawand
 
Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...
Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...
Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...Ed Kelley
 
2. Data organization
2. Data organization2. Data organization
2. Data organizationin4400
 
Math3010 week 5
Math3010 week 5Math3010 week 5
Math3010 week 5stanbridge
 
Lesson 6 Nonparametric Test 2009 Ta
Lesson 6 Nonparametric Test 2009 TaLesson 6 Nonparametric Test 2009 Ta
Lesson 6 Nonparametric Test 2009 TaSumit Prajapati
 
Statistical techniques for ordinal data
Statistical techniques for ordinal dataStatistical techniques for ordinal data
Statistical techniques for ordinal dataAndi Koentary
 
Point Bicerial Correlation Coefficient
Point Bicerial Correlation CoefficientPoint Bicerial Correlation Coefficient
Point Bicerial Correlation CoefficientSharlaine Ruth
 
Correlation and regression
Correlation and regressionCorrelation and regression
Correlation and regressioncbt1213
 
Chapter 11
Chapter 11Chapter 11
Chapter 11bmcfad01
 
Hypothesis testing an introduction
Hypothesis testing an introductionHypothesis testing an introduction
Hypothesis testing an introductionGeetika Gulyani
 
Test of hypothesis (z)
Test of hypothesis (z)Test of hypothesis (z)
Test of hypothesis (z)Marlon Gomez
 
Test of hypothesis
Test of hypothesisTest of hypothesis
Test of hypothesisJaspreet1192
 
Brm (one tailed and two tailed hypothesis)
Brm (one tailed and two tailed hypothesis)Brm (one tailed and two tailed hypothesis)
Brm (one tailed and two tailed hypothesis)Upama Dwivedi
 
Thiyagu normal probability curve
Thiyagu   normal probability curveThiyagu   normal probability curve
Thiyagu normal probability curveThiyagu K
 
Methods of organizing data
Methods of organizing dataMethods of organizing data
Methods of organizing dataRoxane La'O
 

Viewers also liked (20)

Hypothesis testing examples on z test
Hypothesis testing examples on z testHypothesis testing examples on z test
Hypothesis testing examples on z test
 
T test, independant sample, paired sample and anova
T test, independant sample, paired sample and anovaT test, independant sample, paired sample and anova
T test, independant sample, paired sample and anova
 
Test of hypothesis
Test of hypothesisTest of hypothesis
Test of hypothesis
 
Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...
Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...
Particle Filter Localization for Unmanned Aerial Vehicles Using Augmented Rea...
 
Chapter4
Chapter4Chapter4
Chapter4
 
2. Data organization
2. Data organization2. Data organization
2. Data organization
 
Math3010 week 5
Math3010 week 5Math3010 week 5
Math3010 week 5
 
Lesson 6 Nonparametric Test 2009 Ta
Lesson 6 Nonparametric Test 2009 TaLesson 6 Nonparametric Test 2009 Ta
Lesson 6 Nonparametric Test 2009 Ta
 
Statistical techniques for ordinal data
Statistical techniques for ordinal dataStatistical techniques for ordinal data
Statistical techniques for ordinal data
 
Hypothesis and Test
Hypothesis and TestHypothesis and Test
Hypothesis and Test
 
Point Bicerial Correlation Coefficient
Point Bicerial Correlation CoefficientPoint Bicerial Correlation Coefficient
Point Bicerial Correlation Coefficient
 
Regression
RegressionRegression
Regression
 
Correlation and regression
Correlation and regressionCorrelation and regression
Correlation and regression
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Hypothesis testing an introduction
Hypothesis testing an introductionHypothesis testing an introduction
Hypothesis testing an introduction
 
Test of hypothesis (z)
Test of hypothesis (z)Test of hypothesis (z)
Test of hypothesis (z)
 
Test of hypothesis
Test of hypothesisTest of hypothesis
Test of hypothesis
 
Brm (one tailed and two tailed hypothesis)
Brm (one tailed and two tailed hypothesis)Brm (one tailed and two tailed hypothesis)
Brm (one tailed and two tailed hypothesis)
 
Thiyagu normal probability curve
Thiyagu   normal probability curveThiyagu   normal probability curve
Thiyagu normal probability curve
 
Methods of organizing data
Methods of organizing dataMethods of organizing data
Methods of organizing data
 

Similar to parametric hypothesis testing using MATLAB

T test^jsample size^j ethics
T test^jsample size^j ethicsT test^jsample size^j ethics
T test^jsample size^j ethicsAbhishek Thakur
 
t Test- Thiyagu
t Test- Thiyagut Test- Thiyagu
t Test- ThiyaguThiyagu K
 
Chi square test social research refer.ppt
Chi square test social research refer.pptChi square test social research refer.ppt
Chi square test social research refer.pptSnehamurali18
 
Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...
Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...
Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...The Stockker
 
Day-2_Presentation for SPSS parametric workshop.pptx
Day-2_Presentation for SPSS parametric workshop.pptxDay-2_Presentation for SPSS parametric workshop.pptx
Day-2_Presentation for SPSS parametric workshop.pptxrjaisankar
 
Practice test ch 10 correlation reg ch 11 gof ch12 anova
Practice test ch 10 correlation reg ch 11 gof ch12 anovaPractice test ch 10 correlation reg ch 11 gof ch12 anova
Practice test ch 10 correlation reg ch 11 gof ch12 anovaLong Beach City College
 
Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric)
Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric) Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric)
Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric) Dexlab Analytics
 
T12 non-parametric tests
T12 non-parametric testsT12 non-parametric tests
T12 non-parametric testskompellark
 

Similar to parametric hypothesis testing using MATLAB (20)

Parametric test
Parametric testParametric test
Parametric test
 
T test^jsample size^j ethics
T test^jsample size^j ethicsT test^jsample size^j ethics
T test^jsample size^j ethics
 
t Test- Thiyagu
t Test- Thiyagut Test- Thiyagu
t Test- Thiyagu
 
Chi square test social research refer.ppt
Chi square test social research refer.pptChi square test social research refer.ppt
Chi square test social research refer.ppt
 
Student t test
Student t testStudent t test
Student t test
 
Non parametric-tests
Non parametric-testsNon parametric-tests
Non parametric-tests
 
Hypothesis
HypothesisHypothesis
Hypothesis
 
Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...
Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...
Research methodology - Estimation Theory & Hypothesis Testing, Techniques of ...
 
Day-2_Presentation for SPSS parametric workshop.pptx
Day-2_Presentation for SPSS parametric workshop.pptxDay-2_Presentation for SPSS parametric workshop.pptx
Day-2_Presentation for SPSS parametric workshop.pptx
 
The t test mean comparison 1
The t test mean comparison 1The t test mean comparison 1
The t test mean comparison 1
 
Practice test ch 10 correlation reg ch 11 gof ch12 anova
Practice test ch 10 correlation reg ch 11 gof ch12 anovaPractice test ch 10 correlation reg ch 11 gof ch12 anova
Practice test ch 10 correlation reg ch 11 gof ch12 anova
 
Resampling methods
Resampling methodsResampling methods
Resampling methods
 
Day 3 SPSS
Day 3 SPSSDay 3 SPSS
Day 3 SPSS
 
One way AVOVA
One way AVOVA  One way AVOVA
One way AVOVA
 
TEST OF SIGNIFICANCE.pptx
TEST OF SIGNIFICANCE.pptxTEST OF SIGNIFICANCE.pptx
TEST OF SIGNIFICANCE.pptx
 
T-Test
T-TestT-Test
T-Test
 
Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric)
Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric) Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric)
Basic of Statistical Inference Part-V: Types of Hypothesis Test (Parametric)
 
Ttest
TtestTtest
Ttest
 
T12 non-parametric tests
T12 non-parametric testsT12 non-parametric tests
T12 non-parametric tests
 
Comparing means
Comparing meansComparing means
Comparing means
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

parametric hypothesis testing using MATLAB

  • 1. Sampling and Hypothesis Testing(I) in MATLAB Kajal Rai kajalrai.pu@gmail.com
  • 2. Contents: • Sampling • Hypothesis Test • Types of parametric test • One sample t-test • Paired t-test • Tailed t-test • Two sample t-test • z-test • F-test • Difference between t-test, z-test and F-test
  • 3. Sampling: • Sampling is the technique to be used in selecting the items for the sample from the population. • Simple Random Sampling: In which each and every unit of the population has an equal opportunity of being selected in the sample. • Can be done with or without replacement. • If done with replacement, then each item has a probability of 1/N of being drawn at each selection. • If done without replacement, then the first item has a probability of 1/N, second item has 1/(N-1) and so on of being drawn.
  • 4. Random Sampling in MATLAB • y = randsample(n,k) returns a vector of k sample of values sampled uniformly at random, without replacement, from the integers 1 to n. • y = randsample(population,k) returns a vector of k values sampled uniformly at random, without replacement, from the values in the vector population.
  • 5. Random Sampling in MATLAB cntd… • y = randsample(n,k,replacement) or y = randsample(population,k,replacement) returns a sample taken with replacement if replacement is true, or without replacement if replacement is false. By default it is false.
  • 6.
  • 7. Random Sampling in MATLAB cntd… • y = randsample(n,k,true,w) or y = randsample(population,k,true,w) returns a weighted sample taken with replacement, using a vector of positive weights w, whose length is n. The probability that the integer i is selected for an entry of y is w(i)/sum(w). Where, w is a vector of probabilities. • randsample does not support weighted sampling without replacement.
  • 8. Generate a random sequence of the characters A, C, G, and T, with replacement, according to the specified probabilities.
  • 9. Hypothesis Tests: • A hypothesis test is a procedure for determining if an assertion about a characteristic of a population is correct. • In hypothesis testing, the goal is to see if there is sufficient statistical evidence to accept a presumed null hypothesis or to reject the alternative hypothesis[1]. • The null hypothesis is usually denoted H0 while the alternative hypothesis is usually denoted H1.
  • 10. Types of parametric test: • One sample t-test: The one-sample t-test is used when we want to know whether our sample comes from a particular population but we do not have full population information available to us. Used when we don't know the variance. • Paired t-test: A paired t-test looks at the difference between paired values in two samples, takes into account the variation of values within each sample, and produces a single number known as a t-value. • Two sample t-test:To compare responses from two groups. These two groups can come from different experimental treatments, or different "populations". • z-test: It is an appropriate parametric statistical procedure when there is one sample that is being compared to a population with a known mean and standard deviation. • F-test: The F-test is designed to test if two population variances are equal.
  • 11. One sample t-test: • [h,p,ci,stat] = ttest(X,M) performs a t-test of the hypothesis that the data in X come from a distribution with mean M. • CI returns a 100*(1-ALPHA)% confidence interval for the true mean of X. • STATS returns a structure with the following fields: • 'tstat' -- the value of the test statistic • 'df' -- the degrees of freedom of the test • 'sd' -- the estimated population standard deviation.
  • 12. One sample t-test example: • Ex: The specimen of copper wires drawn form a large lot have the following breaking strength (in kg. weight): • 578, 572, 570, 568, 572, 578, 570, 572, 596, 544 • Test (using Student’s t-statistic)whether the mean breaking strength of the lot may be taken to be 578 kg. weight (Test at 5 per cent level of significance).
  • 13.
  • 14.
  • 15. t-test with own significance level: • [h,p,ci,stat] = TTEST(...,ALPHA) performs the test at the significance level (100*ALPHA)%. ALPHA must be a scalar.
  • 16. Paired t-test: • A paired t-test looks at the difference between paired values in two samples, takes into account the variation of values within each sample, and produces a single number known as a t-value.
  • 17. Paired t-test in MATLAB: • H = TTEST(X,Y) performs a paired T-test of the hypothesis that two matched samples, in the vectors X and Y, come from distributions with equal means. The difference X-Y is assumed to come from a normal distribution with unknown variance. • X and Y must have the same length.
  • 18. Example: Paired t-test • Memory capacity of 9 students was tested before and after training. State at 5 percent level of significance whether the training was effective from the following scores: • Before:10,15,9,3,7,12,16,17,4 • After:12,17,8,5,6,11,18,20,3 • Take the score before training as X and the score after training as Y and then taking the null hypothesis that the mean of difference is zero
  • 19. we accept H0 and conclude that the difference in score before and after training is insignificant i.e., it is only due to sampling fluctuations. Hence we can infer that the training was not effective.
  • 20. Tailed t-test: • A one- or two-tailed t-test is determined by whether the total area of α is placed in one tail or divided equally between the two tails. • The one-tailed t-test is performed if the results are interesting only if they turn out in a particular direction. • The two-tailed t-test is performed if the results would be interesting in either direction. ααα
  • 21. One-Tailed t-Test: • There are two different one-tailed t-tests, one for each tail. • In a one-tailed t-test, all the area associated with α is placed in either one tail or the other. Selection of the tail depends upon which direction t would be (+ or -) if the results of the experiment came out as expected. • The selection of the tail must be made before the experiment is conducted and analyzed. • Test to see whether one mean was higher than the other.
  • 22. One-tailed t-test in the positive direction The value tcrit would be positive. For example when α is set to .05 with ten degrees of freedom (df=10), tcrit would be equal to +1.812.
  • 23. One-tailed t-test in the negative direction The value tcrit would be negative. For example, when αis set to .05 with ten degrees of freedom (df=10), tcrit would be equal to -1.812.
  • 24. Two-Tailed t-Test: • A two-tailed t-test divides αin half, placing half in the each tail. The null hypothesis in this case is a particular value, and there are two alternative hypotheses, one positive and one negative. The critical value of t, tcrit, is written with both a plus and minus sign (± ). For example, the critical value of t when there are ten degrees of freedom (df=10) and α is set to .05, is tcrit= ± 2.228. • We would use a two-tailed test to see if two means are different from each other (ie from different populations), or from the same population.
  • 25. Tailed t-test in MATLAB • H = TTEST(...,TAIL) performs the test against the alternative hypothesis specified by TAIL: • 'both' -- "mean is M" (two-tailed test) • 'right' -- "mean is greater than M" (right-tailed test) • 'left' -- "mean is less than M" (left-tailed test)
  • 26. One tailed t-test in MATLAB
  • 28. Two sample t-test • H = TTEST2(X,Y) performs a T-test of the hypothesis that two independent samples, in the vectors X and Y, come from distributions with equal means, and returns the result of the test in H. • H=0 indicates that the null hypothesis ("means are equal") cannot be rejected at the 5% significance level. H=1 indicates that the null hypothesis can be rejected at the 5% level. • The data are assumed to come from normal distributions with unknown, but equal, variances. • X and Y can have different lengths.
  • 29. Example: • A group of seven-week old chickens reared on a high protein diet weight 12, 15, 11, 16, 14, 14, and 16, a second group of five chickens, similarly treated except that they receive a low protein diet, weight 8, 10, 14, 10 and 13. Testing at 5 percent level whether there is significant evidence that additional protein has increased the weight of the chickens. Using assumed mean = 10 for the sample of 7 and assumed mean = 8 for the sample of 5 chickens in our calculations. • Taking the null hypothesis that additional protein has not increased the weight of the chickens
  • 30. Two sample t-test in MATLAB we reject H0 and conclude that additional protein has increased the weight of chickens, at 5 per cent level of significance.
  • 31. Two sample t-test in MATLAB cntd… • H = TTEST2(X,Y,ALPHA,TAIL,VARTYPE) allows you to specify the type of test. When VARTYPE is 'equal', TTEST2 performs the default test assuming equal variances. • When VARTYPE is 'unequal', TTEST2 performs the test assuming that the two samples come from normal distributions with unknown and unequal variances. This is known as the Behrens-Fisher problem.
  • 32. z-test in MATLAB A z-test is used for testing the mean of a population or comparing the means of two populations, with large (n ≥ 30) samples when we know the population standard deviation. • H = ZTEST(X,M,SIGMA) performs a Z-test of the hypothesis that the data in the vector X come from a distribution with mean M, and returns the result of the test in H. • H=0 indicates that the null hypothesis ("mean is M") cannot be rejected at the 5% significance level. H=1 indicates that the null hypothesis can be rejected at the 5% level. • The data are assumed to come from a normal distribution with standard deviation SIGMA.
  • 33. Example: • A dog food manufacturer, had created new Super Vitamin Enriched Puppy Chow, specially designed for the active and growing Doberman Pincer. • The sample of 10 Doberman puppies are 27.5, 33.5, 36.8, 39.5, 40.5, 42.5, 40.0, 22.9, 39.8, 40.8 and fed them nothing but with Super Vitamin Enriched Puppy Chow. When these dogs reached adulthood, they weighed 39.7 kg on average (M) and σ = 6.2 kg • Did Puppy Chow make them grow especially big, test with a = .05? • H0: The puppy chow did make the dogs grow more than normal. • H1: The puppy chow did not make the dogs grow larger than normal
  • 34. We will accept H0 and conclude that the Super Vitamin Enriched Puppy Chow makes Doberman Pincers grow significantly larger.
  • 35. F-test: • F-test is used to compare the variance of the two-independent samples. • This test is also used in the context of analysis of variance (ANOVA) for judging the significance of more than two sample means at one and the same time. • It is also used for judging the significance of multiple correlation coefficients.
  • 36. F-test in MATLAB • H = vartest2(X,Y) performs an F test of the hypothesis that two independent samples, in the vectors X and Y, come from normal distributions with the same variance, against the alternative that they come from normal distributions with different variances. • The result is H=0 if the null hypothesis ("variances are equal") cannot be rejected at the 5% significance level, or H=1 if the null hypothesis can be rejected at the 5% level. • X and Y can have different lengths.
  • 37. Example: • Two random samples drawn from two normal populations are: • Sample1: 20 16 26 27 23 22 18 24 25 19 • Sample2: 27 33 42 35 32 34 38 28 41 43 30 37 • At 5% significance level. • We take the null hypothesis that the two populations from where the samples have been drawn have the same variances
  • 38. Since p value is more than 0.05 as such we accept the null hypothesis and conclude that samples have been drawn from two populations having the same variances.
  • 39. Difference between t-test, z-test and F-test: t-test z-test F-test A t-test is used for testing the mean of one population against a standard or comparing the means of two populations. And when you do not know the populations’ standard deviation and when you have a limited sample (n < 30). A z-test is used for testing the mean of a population versus a standard, or comparing the means of two populations, with large (n ≥ 30) samples when we know the population standard deviation. It is also used for testing the proportion of some characteristic versus a standard proportion, or comparing the proportions of two populations. An F-test is used to compare 2 populations’ variances. The samples can be any size. It is the basis of ANOVA.
  • 40. References: • Kothari, C.R.,1985, Research Methodology- Methods and Techniques, New Delhi, Wiley Eastern Limited. • S.P.Gupta,Statistical Methods,eight revised edition 2009 • http://www.mathworks.in/help/stats/ztest.html#btriieq • http://www.math.uah.edu/stat/hypothesis/Introduction.html • http://www.mathworks.in/products/statistics/description7.html • How to Do a T-Test in MATLAB eHow http://www.ehow.com/how_12211819_ttest- matlab.html#ixzz2WSQ6BN6o