SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

PPT on Sample Size, Importance of Sample Size,
PPT on Sample Size, Importance of Sample Size,PPT on Sample Size, Importance of Sample Size,
PPT on Sample Size, Importance of Sample Size,Naveen K L
 
Wilcoxon Rank-Sum Test
Wilcoxon Rank-Sum TestWilcoxon Rank-Sum Test
Wilcoxon Rank-Sum TestSahil Jain
 
Parametric Statistical tests
Parametric Statistical testsParametric Statistical tests
Parametric Statistical testsSundar B N
 
Introduction to t-tests (statistics)
Introduction to t-tests (statistics)Introduction to t-tests (statistics)
Introduction to t-tests (statistics)Dr Bryan Mills
 
Wilcoxon signed rank test
Wilcoxon signed rank testWilcoxon signed rank test
Wilcoxon signed rank testBiswash Sapkota
 
Parametric tests seminar
Parametric tests seminarParametric tests seminar
Parametric tests seminardrdeepika87
 
Mann Whitney U Test | Statistics
Mann Whitney U Test | StatisticsMann Whitney U Test | Statistics
Mann Whitney U Test | StatisticsTransweb Global Inc
 
P value, Power, Type 1 and 2 errors
P value, Power, Type 1 and 2 errorsP value, Power, Type 1 and 2 errors
P value, Power, Type 1 and 2 errorsRizwan S A
 
Anova and T-Test
Anova and T-TestAnova and T-Test
Anova and T-TestAD Sarwar
 
Parametric tests
Parametric testsParametric tests
Parametric testsheena45
 
Non parametric methods
Non parametric methodsNon parametric methods
Non parametric methodsPedro Moreira
 
Error, bias and confounding
Error, bias and confoundingError, bias and confounding
Error, bias and confoundingMitasha Singh
 
Observational Studies and their Reporting Guidelines
Observational Studies and their Reporting GuidelinesObservational Studies and their Reporting Guidelines
Observational Studies and their Reporting Guidelineskopalsharma85
 

La actualidad más candente (20)

Non parametric presentation
Non parametric presentationNon parametric presentation
Non parametric presentation
 
PPT on Sample Size, Importance of Sample Size,
PPT on Sample Size, Importance of Sample Size,PPT on Sample Size, Importance of Sample Size,
PPT on Sample Size, Importance of Sample Size,
 
Wilcoxon Rank-Sum Test
Wilcoxon Rank-Sum TestWilcoxon Rank-Sum Test
Wilcoxon Rank-Sum Test
 
Parametric Statistical tests
Parametric Statistical testsParametric Statistical tests
Parametric Statistical tests
 
Introduction to t-tests (statistics)
Introduction to t-tests (statistics)Introduction to t-tests (statistics)
Introduction to t-tests (statistics)
 
Student t-test
Student t-testStudent t-test
Student t-test
 
Wilcoxon signed rank test
Wilcoxon signed rank testWilcoxon signed rank test
Wilcoxon signed rank test
 
Kruskal Wall Test
Kruskal Wall TestKruskal Wall Test
Kruskal Wall Test
 
Parametric Test
Parametric TestParametric Test
Parametric Test
 
Parametric tests seminar
Parametric tests seminarParametric tests seminar
Parametric tests seminar
 
Mann Whitney U Test | Statistics
Mann Whitney U Test | StatisticsMann Whitney U Test | Statistics
Mann Whitney U Test | Statistics
 
P value, Power, Type 1 and 2 errors
P value, Power, Type 1 and 2 errorsP value, Power, Type 1 and 2 errors
P value, Power, Type 1 and 2 errors
 
Anova and T-Test
Anova and T-TestAnova and T-Test
Anova and T-Test
 
Parametric tests
Parametric testsParametric tests
Parametric tests
 
Non parametric methods
Non parametric methodsNon parametric methods
Non parametric methods
 
Error, bias and confounding
Error, bias and confoundingError, bias and confounding
Error, bias and confounding
 
9.testing of hypothesis
9.testing of hypothesis9.testing of hypothesis
9.testing of hypothesis
 
Observational Studies and their Reporting Guidelines
Observational Studies and their Reporting GuidelinesObservational Studies and their Reporting Guidelines
Observational Studies and their Reporting Guidelines
 
Non parametric-tests
Non parametric-testsNon parametric-tests
Non parametric-tests
 
The mann whitney u test
The mann whitney u testThe mann whitney u test
The mann whitney u test
 

Destacado

DIstinguish between Parametric vs nonparametric test
 DIstinguish between Parametric vs nonparametric test DIstinguish between Parametric vs nonparametric test
DIstinguish between Parametric vs nonparametric testsai prakash
 
Parametric vs Nonparametric Tests: When to use which
Parametric vs Nonparametric Tests: When to use whichParametric vs Nonparametric Tests: When to use which
Parametric vs Nonparametric Tests: When to use whichGönenç Dalgıç
 
Parametric and non parametric test
Parametric and non parametric testParametric and non parametric test
Parametric and non parametric testAjay Malpani
 
Nonparametric tests
Nonparametric testsNonparametric tests
Nonparametric testsArun Kumar
 
Hypothesis testing ppt final
Hypothesis testing ppt finalHypothesis testing ppt final
Hypothesis testing ppt finalpiyushdhaker
 
Hypothesis testing; z test, t-test. f-test
Hypothesis testing; z test, t-test. f-testHypothesis testing; z test, t-test. f-test
Hypothesis testing; z test, t-test. f-testShakehand with Life
 
Research hypothesis....ppt
Research hypothesis....pptResearch hypothesis....ppt
Research hypothesis....pptRahul Dhaker
 
Mann Whitney U Test And Chi Squared
Mann Whitney U Test And Chi SquaredMann Whitney U Test And Chi Squared
Mann Whitney U Test And Chi Squaredguest2137aa
 
Formulating hypotheses
Formulating hypothesesFormulating hypotheses
Formulating hypothesesAniket Verma
 
Basic Concept Of Probability
Basic Concept Of ProbabilityBasic Concept Of Probability
Basic Concept Of Probabilityguest45a926
 
Test of hypothesis
Test of hypothesisTest of hypothesis
Test of hypothesisvikramlawand
 

Destacado (20)

DIstinguish between Parametric vs nonparametric test
 DIstinguish between Parametric vs nonparametric test DIstinguish between Parametric vs nonparametric test
DIstinguish between Parametric vs nonparametric test
 
Parametric vs Nonparametric Tests: When to use which
Parametric vs Nonparametric Tests: When to use whichParametric vs Nonparametric Tests: When to use which
Parametric vs Nonparametric Tests: When to use which
 
Parametric and non parametric test
Parametric and non parametric testParametric and non parametric test
Parametric and non parametric test
 
Nonparametric tests
Nonparametric testsNonparametric tests
Nonparametric tests
 
Berd 5-6
Berd 5-6Berd 5-6
Berd 5-6
 
Hypothesis testing ppt final
Hypothesis testing ppt finalHypothesis testing ppt final
Hypothesis testing ppt final
 
Hypothesis testing; z test, t-test. f-test
Hypothesis testing; z test, t-test. f-testHypothesis testing; z test, t-test. f-test
Hypothesis testing; z test, t-test. f-test
 
Hypothesis Testing
Hypothesis TestingHypothesis Testing
Hypothesis Testing
 
Chi – square test
Chi – square testChi – square test
Chi – square test
 
Hypothesis
HypothesisHypothesis
Hypothesis
 
Z test
Z testZ test
Z test
 
Research hypothesis....ppt
Research hypothesis....pptResearch hypothesis....ppt
Research hypothesis....ppt
 
Mann Whitney U Test And Chi Squared
Mann Whitney U Test And Chi SquaredMann Whitney U Test And Chi Squared
Mann Whitney U Test And Chi Squared
 
Measures of Variation
Measures of VariationMeasures of Variation
Measures of Variation
 
Chi square test
Chi square testChi square test
Chi square test
 
Formulating hypotheses
Formulating hypothesesFormulating hypotheses
Formulating hypotheses
 
Basic Concept Of Probability
Basic Concept Of ProbabilityBasic Concept Of Probability
Basic Concept Of Probability
 
Lesson p values
Lesson   p valuesLesson   p values
Lesson p values
 
P value
P valueP value
P value
 
Test of hypothesis
Test of hypothesisTest of hypothesis
Test of hypothesis
 

Similar a Parametric test

parametric hypothesis testing using MATLAB
parametric hypothesis testing using MATLABparametric hypothesis testing using MATLAB
parametric hypothesis testing using MATLABKajal Saraswat
 
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
 
Statistical tests of significance and Student`s T-Test
Statistical tests of significance and Student`s T-TestStatistical tests of significance and Student`s T-Test
Statistical tests of significance and Student`s T-TestVasundhraKakkar
 
hypothesisTestPPT.pptx
hypothesisTestPPT.pptxhypothesisTestPPT.pptx
hypothesisTestPPT.pptxdangwalakash07
 
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
 
C2 st lecture 11 the t-test handout
C2 st lecture 11   the t-test handoutC2 st lecture 11   the t-test handout
C2 st lecture 11 the t-test handoutfatima d
 
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
 
Point Estimate, Confidence Interval, Hypotesis tests
Point Estimate, Confidence Interval, Hypotesis testsPoint Estimate, Confidence Interval, Hypotesis tests
Point Estimate, Confidence Interval, Hypotesis testsUniversity of Salerno
 
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
 
T test^jsample size^j ethics
T test^jsample size^j ethicsT test^jsample size^j ethics
T test^jsample size^j ethicsAbhishek Thakur
 
Statistical Significance Tests.pptx
Statistical Significance Tests.pptxStatistical Significance Tests.pptx
Statistical Significance Tests.pptxAldofChrist
 
t Test- Thiyagu
t Test- Thiyagut Test- Thiyagu
t Test- ThiyaguThiyagu K
 
Research methodology module 3
Research methodology module 3Research methodology module 3
Research methodology module 3Satyajit Behera
 
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
 

Similar a Parametric test (20)

parametric hypothesis testing using MATLAB
parametric hypothesis testing using MATLABparametric hypothesis testing using MATLAB
parametric hypothesis testing using MATLAB
 
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
 
Day 3 SPSS
Day 3 SPSSDay 3 SPSS
Day 3 SPSS
 
TEST OF SIGNIFICANCE.pptx
TEST OF SIGNIFICANCE.pptxTEST OF SIGNIFICANCE.pptx
TEST OF SIGNIFICANCE.pptx
 
Statistical tests of significance and Student`s T-Test
Statistical tests of significance and Student`s T-TestStatistical tests of significance and Student`s T-Test
Statistical tests of significance and Student`s T-Test
 
hypothesisTestPPT.pptx
hypothesisTestPPT.pptxhypothesisTestPPT.pptx
hypothesisTestPPT.pptx
 
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
 
C2 st lecture 11 the t-test handout
C2 st lecture 11   the t-test handoutC2 st lecture 11   the t-test handout
C2 st lecture 11 the t-test handout
 
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 ...
 
TEST of hypothesis
TEST of hypothesisTEST of hypothesis
TEST of hypothesis
 
Point Estimate, Confidence Interval, Hypotesis tests
Point Estimate, Confidence Interval, Hypotesis testsPoint Estimate, Confidence Interval, Hypotesis tests
Point Estimate, Confidence Interval, Hypotesis tests
 
T- test .pptx
T- test .pptxT- test .pptx
T- test .pptx
 
Talk 3
Talk 3Talk 3
Talk 3
 
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)
 
T test^jsample size^j ethics
T test^jsample size^j ethicsT test^jsample size^j ethics
T test^jsample size^j ethics
 
Hypothesis
HypothesisHypothesis
Hypothesis
 
Statistical Significance Tests.pptx
Statistical Significance Tests.pptxStatistical Significance Tests.pptx
Statistical Significance Tests.pptx
 
t Test- Thiyagu
t Test- Thiyagut Test- Thiyagu
t Test- Thiyagu
 
Research methodology module 3
Research methodology module 3Research methodology module 3
Research methodology module 3
 
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
 

Más de Chinnannan Periasamy (15)

MCT
MCTMCT
MCT
 
Inventory notes
Inventory notesInventory notes
Inventory notes
 
Qtmd syllabus
Qtmd syllabusQtmd syllabus
Qtmd syllabus
 
Ec 15 101 advanced engineering mathematics
Ec 15 101 advanced engineering mathematicsEc 15 101 advanced engineering mathematics
Ec 15 101 advanced engineering mathematics
 
Fourier transform
Fourier transformFourier transform
Fourier transform
 
Avg q lenth
Avg q lenthAvg q lenth
Avg q lenth
 
Chi sq explanation
Chi sq explanationChi sq explanation
Chi sq explanation
 
HYPOTHESES STEPS
HYPOTHESES STEPSHYPOTHESES STEPS
HYPOTHESES STEPS
 
11.00 technology ok
11.00 technology ok11.00 technology ok
11.00 technology ok
 
segmentation
segmentationsegmentation
segmentation
 
1.11 functions of money ppt-ok
1.11 functions of money ppt-ok1.11 functions of money ppt-ok
1.11 functions of money ppt-ok
 
Listening
ListeningListening
Listening
 
decision
decisiondecision
decision
 
M tech regulations
M tech regulationsM tech regulations
M tech regulations
 
1.iib ppt
1.iib ppt1.iib ppt
1.iib ppt
 

Parametric test

  • 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