Professional Documents
Culture Documents
EA Project Term Paper
EA Project Term Paper
EA Project Term Paper
Introduction ..................................................................................................................................... 3
Understanding Hypothesis Testing ................................................................................................. 4
Key Terms of Hypothesis Testing ............................................................................................... 4
Errors in Hypothesis Testing ....................................................................................................... 5
Hypothesis Testing work Process ............................................................................................... 6
Figuring Out the Test Statistic ........................................................................................................ 8
Types of Statistical Data Distributions ....................................................................................... 8
Process Of Test Statistics ................................................................................................................ 9
Chi-Square Test ........................................................................................................................... 9
Z-Statistics Test ......................................................................................................................... 13
T-Test Statistics ......................................................................................................................... 14
Problem Analyse ........................................................................................................................... 18
Z-Test Problem Analyse ............................................................................................................ 18
Python Simulation................................................................................................................. 18
T-Test Problem Analyse ............................................................................................................ 19
Python Simulation................................................................................................................. 19
Conclusion .................................................................................................................................... 20
References ..................................................................................................................................... 20
Abstract
Hypothesis testing stands as a cornerstone of statistical analysis, offering a systematic approach to
draw conclusions about populations from sample data. This abstract provides an overview of
hypothesis testing methodologies, focusing on the t-test, z-test, and chi-square test.
The t-test and z-test serve as primary tools for comparing means, with the former suited for smaller
samples or unknown population standard deviations, while the latter is preferable for larger
samples or known standard deviations. These tests enable researchers to assess the significance of
differences in means, aiding decision-making processes across diverse fields.
In addition to mean comparison, the chi-square test facilitates the examination of associations
between categorical variables. Its versatility is manifested in various applications, including tests
for independence, goodness of fit, and homogeneity.
Through hypothesis testing, researchers can navigate uncertainties, validate assumptions, and
contribute to the advancement of knowledge within their domains. This abstract underscore the
significance of hypothesis testing as a foundational methodology in statistical inference and
empirical research.
2
Introduction
Hypothesis testing is a fundamental statistical method used to make inferences about populations
based on sample data. It serves as a powerful tool in decision-making across various fields, from
healthcare to economics to social sciences. At its core, hypothesis testing enables researchers to
evaluate assumptions or claims about a population parameter and determine whether there is
enough evidence to support or reject those assertions.
One of the most common types of hypothesis tests involves comparing the mean of a sample to a
known or hypothesized population mean. This is often done using either the t-test or the z-test,
depending on the characteristics of the sample and the available information about the population.
The t-test is widely employed when the sample size is small (typically less than 30) or when the
population standard deviation is unknown. It assesses whether there is a significant difference
between the means of two groups or whether the mean of a single group differs from a
hypothesized value. The t-test calculates a test statistic based on the sample mean, standard
deviation, and sample size, comparing it to a t-distribution to determine the likelihood of observing
such a result if the null hypothesis (the assumption being tested) were true.
In contrast, the z-test is utilized when the sample size is large (typically greater than 30) or when
the population standard deviation is known. It follows a similar principle to the t-test but employs
the standard normal distribution instead of the t-distribution. This makes the z-test more suitable
for situations where the sample size is sufficiently large to assume that the sampling distribution
of the sample mean is approximately normal.
Another type of hypothesis test, the chi-square test, is commonly used to assess the association
between categorical variables. Unlike the t-test and z-test, which focus on comparing means, the
chi-square test evaluates whether there is a significant association between two categorical
variables by comparing observed frequencies to expected frequencies under the null hypothesis of
independence.
The chi-square test can take various forms depending on the specific research question and the
nature of the data, such as the chi-square test for independence, the chi-square test for goodness of
fit, and the chi-square test for homogeneity.
In summary, hypothesis testing provides a systematic framework for drawing conclusions about
populations based on sample data. Whether comparing means with the t-test or z-test or assessing
associations with the chi-square test, researchers can leverage these statistical methods to make
informed decisions and contribute to the advancement of knowledge in their respective fields.
3
Understanding Hypothesis Testing
Hypothesis testing encompasses creating suppositions about population characteristics using data
from samples and systematically examining these suppositions against real-world observations.
This piece illuminates the importance of hypothesis testing and outlines the essential stages within
this procedure.
Defining Hypotheses
Null hypothesis (H0): In statistics, the null hypothesis is a general statement or default position that
there is no relationship between two measured cases or no relationship among groups. In other
words, it is a basic assumption or made based on the problem knowledge.
Example: A company’s mean production is 50 units/per da H0: µ = 50.
Alternative hypothesis (H1): The alternative hypothesis is the hypothesis used in hypothesis testing
that is contrary to the null hypothesis.
Example: A company’s production is not equal to 50 units/per day i.e. H1: µ ≠50.
4
critical value or p-value to make decisions about the statistical significance of the observed
results.
• Critical value: The critical value in statistics is a threshold or cutoff point used to
determine whether to reject the null hypothesis in a hypothesis test.
• Degrees of freedom: Degrees of freedom are associated with the variability or freedom
one has in estimating a parameter. The degrees of freedom are related to the sample size
and determine the shape.
Why do we use Hypothesis Testing?
Hypothesis testing is an important procedure in statistics. Hypothesis testing evaluates two
mutually exclusive population statements to determine which statement is most supported by
sample data. When we say that the findings are statistically significant, thanks to hypothesis
testing.
One-Tailed and Two-Tailed Test
One tailed test focuses on one direction, either greater than or less than a specified value. We use
a one-tailed test when there is a clear directional expectation based on prior knowledge or theory.
The critical region is located on only one side of the distribution curve. If the sample falls into this
critical region, the null hypothesis is rejected in favor of the alternative hypothesis.
One-Tailed Test
There are two types of one-tailed test:
• Left-Tailed (Left-Sided) Test: The alternative hypothesis asserts that the true parameter
value is less than the null hypothesis. Example: H0: µ ≥ 50 and H1: µ < 50.
• Right-Tailed (Right-Sided) Test: The alternative hypothesis asserts that the true parameter
value is greater than the null hypothesis. Example: H0: µ ≤ 50 and H1: µ > 50.
Two-Tailed Test
A two-tailed test considers both directions, greater than and less than a specified value. We use a
two-tailed test when there is no specific directional expectation, and want to detect any significant
difference. Example: H0: µ = 50 and H1: µ ≠ 50.
5
• Type II errors: When we accept the null hypothesis, but it is false. Type II errors are denoted
by beta(β).
Null Hypothesis is True Null Hypothesis is False
Null Hypothesis is True Correct Decision Type II Error (False
(Accept) Negative)
Alternative Hypothesis is Type I Error (False Positive) Correct Decision
True (Reject)
1. Z-test: If population means and standard deviations are known. Z-statistic is commonly
used.
6
2. t-test: If population standard deviations are unknown. and sample size is small than t-test
statistic is more appropriate.
3. Chi-square test: Chi-square test is used for categorical data or for testing independence in
contingency tables
4. F-test: F-test is often used in analysis of variance (ANOVA) to compare variances or test
the equality of means across multiple groups.
We have a smaller dataset, So, T-test is more appropriate to test our hypothesis.
T-statistic is a measure of the difference between the means of two groups relative to the
variability within each group. It is calculated as the difference between the sample means
divided by the standard error of the difference. It is also known as the t-value or t-score.
7
Step 7: Interpret the Results
At last, we can conclude our experiment using method A or B.
Distribution simply means collection or gathering of data, or scores, on variable. Generally, all
these scores are arranged in specific order from smallest to largest. Then these scores can be
presented graphically. Many data comply with rules of well-known and highly understood
functions of mathematics.
Distributions are generally described in terms of their density or density functions. Density
functions are simply described as functions that explain how proportion of data or likelihood of
proportion of observations change over wide range of distribution. Density functions are of two
types –
Cumulative Density Function (CDF) – It calculates probability of an observation equal or less than
value.
1. Gaussian Distribution
It is named after Carl Friedrich Gauss. Gaussian Distribution is focus of much of field of statistics.
It is also known as Normal Distribution. With use of Gaussian Distribution, data from different
study fields can be described. Generally, Gaussian Distribution is described using two parameters,
Mean: It is denoted with Greek lowercase letter “µ”. It is expected value of distribution.
Variance:
It is denoted with Greek lowercase letter “σ” raised to second power (this is because units of
variables are squared.). It generally describes spread of observation from mean.
8
It is very common and easy to use normalized calculation of variance called Standard Deviation.
Standard Deviation is denoted with Greek lowercase letter “sigma”. It generally describes
normalized spread of observations from mean.
2. T- Distribution
It is named after Willian Sealy Gosset. T- distribution generally arises when we attempt to find out
mean of normal distribution with different sized samples. It is very helpful when describing
uncertainty or error related to estimating or finding out population statistics for data drawn from
Gaussian Distributions when size of sample must be considered. T-distribution can be described
using single parameter.
Normal Distribution:
It the most common or normal form of distribution of Random Variables, hence the name “normal
distribution.” It is also called Gaussian Distribution in Statistics or Probability. We use this
distribution to represent a large number of random variables.
Chi-Square Test
Chi-Square test is a statistical method crucial for analyzing associations in categorical data. Its
applications span various fields, aiding researchers in understanding relationships between factors.
This article elucidates Chi-Square types, steps for implementation, and its role in feature selection,
exemplified through Python code on the Iris dataset.
What is Chi-Square test?
The chi-square test is a statistical test used to determine if there is a significant association between
two categorical variables. It is a non-parametric test, meaning it makes no assumptions about the
distribution of the data. The test is based on the comparison of observed and expected frequencies
within a contingency table. The chi-square test helps with feature selection problems by looking
at the relationship between the elements. It determines if the association between two categorical
variables of the sample would reflect their real association in the population.
9
where
• c is degree of freedom
• Oij is the observed frequency in cell ij
• Eij is the expected frequency in cell ij
Chi-Square Distribution
The chi-square distribution is a continuous probability distribution that arises in statistics and is
associated with the sum of the squares of independent standard normal random variables. It is often
denoted as x2 and is parameterized by the degrees of freedom k.
It is widely used in statistical analysis, particularly in hypothesis testing and calculating confidence
intervals. It is often used with non-normally distributed data.
10
1. Chi-Square Test for Independence: This test assesses whether there is a significant
association or relationship between two categorical variables. It is used to determine
whether changes in one variable are independent of changes in another. This test is applied
when we have counts of values for two nominal or categorical variables. To conduct this
test, two requirements must be met:
independence of observations and a relatively large sample size.
For example, suppose we are interested in exploring whether there is a relationship between
online shopping preferences and the payment methods people choose. The first variable is
the type of online shopping preference (e.g., Electronics, Clothing, Books), and the second
variable is the chosen payment method (e.g., Credit Card, Debit Card, PayPal).
The null hypothesis in this case would be that the choice of online shopping preference and
the selected payment method are independent.
2. Chi-Square Goodness-of-Fit Test: The Chi-Square Goodness-of-Fit test is used in statistical
hypothesis testing to ascertain whether a variable is likely from a given distribution or not.
This test can be applied in situations when we have value counts for categorical variables.
With the help of this test, we can determine whether the data values are a representative
sample of the entire population or if they fit our hypothesis well.
For example, imagine you are testing the fairness of a six-sided die. The null hypothesis is
that each face of the die should have an equal probability of landing face up. In other words,
the die is unbiased, and the proportions of each number (1 through 6) occurring are
expected to be equal.
11
1. Define
• Null Hypothesis (H0): There is no significant association between the two categorical
variables.
• Alternative Hypothesis (H1): There is a significant association between the two categorical
variables.
2. Create a contingency table that displays the frequency distribution of the two categorical
variables.
3. Find the Expected values using formula:
𝑅𝑖 × 𝐶𝑗
𝐸𝑖𝑗 =
𝑁
where
• Ri: Totals of row i.
• Cj: Totals of column j
• N: Total number of Observations
where
• m corresponds to the number of categories in one categorical variable.
• n corresponds to the number of categories in another categorical variable.
6. Accept or Reject the Null Hypothesis: Compare the calculated chi-square statistic to the
critical value from the chi-square distribution table for the chosen significance level (e.g.,
0.05)
• If x2 is greater than the critical value, reject the null hypothesis, indicating a
significant association between the variables.
• If x2 is less than or equal to the critical value, fail to reject the null hypothesis,
suggesting no significant association.
Statistical functions are used to verify our population parameter hypothesis. For data that is
Normally distributed, we use the z-score, p-value, and degree of significance (alpha) to provide
evidence in support of our hypothesis.
12
Z-Statistics Test
In statistics, several tests are used to compare different groups or samples to draw inferences about
populations. These tests, which are also known as statistical tests, focus on determining how likely
it is that the observed data will be obtained under specific premises or hypotheses. They provide a
framework for assessing the data supporting or refuting a certain hypothesis.
A statistical test starts with the formulation of a null hypothesis (H0) and an alternative hypothesis
(Ha). The alternative hypothesis proposes a particular link or effect, whereas the null hypothesis
reflects the default assumption and often states no effect or no difference.
The Z-test is a statistical technique that is employed to ascertain whether or not the distribution of
the test results can be roughly represented by the normal distribution. When the variance of two
sample means is known and the sample size is big (i.e., >= 30), this method determines if the
sample means are roughly the same or different.
Steps of Z test:
1. First, identify the null and alternate hypotheses.
2. Determine the level of significance (∝).
3. Find the critical value of z in the z-test using.
4. Calculate the z-test statistics. Below is the formula for calculating the z-test statistics.
5. Compare Z- Test statistics value with the Z-critical Value.
𝑿−𝝁
𝒁= 𝝈
√𝒏
Where:
𝑋̅ = mean of the sample.
𝜇 = mean of the population.
𝜎 = Standard deviation of the population.
n = sample size.
Type of Z-test
Left-tailed Test:
In this test, our region of rejection is located to the extreme left of the distribution. Here our null
hypothesis is that the claimed value is less than or equal to the mean population value.
13
Right-tailed Test:
In this test, our region of rejection is located to the extreme right of the distribution. Here our null
hypothesis is that the claimed value is less than or equal to the mean population value.
Two-tailed test:
In this test, our region of rejection is located to both extremes of the distribution. Here our null
hypothesis is that the claimed value is equal to the mean population value.
T-Test Statistics
The t-test is named after William Sealy Gosset’s Student’s t-distribution, created while he was
writing under the pen name “Student”. A t-test is a type of inferential statistic test used to determine
if there is a significant difference between the means of two groups. It is often used when data is
normally distributed and population variance is unknown. The t-test is used in hypothesis testing
to assess whether the observed difference between the means of the two groups is statistically
significant or just due to random variation.
Assumptions in T-test
• Independence: The observations within each group must be independent of each other.
This means that the value of one observation should not influence the value of another
observation. Violations of independence can occur with repeated measures, paired data, or
clustered data.
14
• Normality: The data within each group should be approximately normally distributed i.e
the distribution of the data within each group being compared should resemble a normal
(bell-shaped) distribution. This assumption is crucial for small sample sizes (n < 30).
• Homogeneity of Variances (for independent samples t-test): The variances of the two
groups being compared should be equal. This assumption ensures that the groups have a
similar spread of values. Unequal variances can affect the standard error of the difference
between means and, consequently, the t-statistic.
• Absence of Outliers: There should be no extreme outliers in the data as outliers can
disproportionately influence the results, especially when sample sizes are small.
15
• If the t-value is large => the two groups belong to different groups.
• If the t-value is small => the two groups belong to the same group.
T-Distribution
The t-distribution, commonly known as the student’s t-distribution, is a probability distribution
with tails that are thicker than those of the normal distribution.
Statistical Significance
Statistical significance is determined by comparing the p-value to the chosen significance level.
• If the p-value is less than or equal to the significance level, the result is considered
statistically significant, and the null hypothesis is rejected.
• If the p-value is greater than the significance level, the result is not statistically significant,
and there is insufficient evidence to reject the null hypothesis.
In the context of a t-test, these concepts are applied to compare means between two groups. The t-
test assesses whether the means are significantly different from each other, taking into account the
variability within the groups. The p-value from the t-test is then compared to the significance level
to make a decision about the null hypothesis.
Types of T-tests
There are three types of t-tests, and they are categorized as dependent and independent t-tests.
• One sample t-test test: The mean of a single group against a known mean.
• Two-sample t-test: It is further divided into two types:
o Independent samples t-test: compares the means for two groups.
o Paired sample t-test: compares means from the same group at different times (say,
one year apart)
One sample t-test Process
𝑿−𝝁
𝒕= 𝝈
√𝒏
Where:
𝑋̅ = mean of the sample.
𝜇 = mean of the population.
𝜎 = Standard deviation of the population.
n = sample size.
16
For T critical Value we have to use below T distribution Table:
17
Problem Analyse
Z-Test Problem Analyse
Let’s say A school claimed that the students who study that are more intelligent than the average
school. On calculating the IQ scores of 50 students, the average turns out to be 110. The mean of
the population IQ is 100 and the standard deviation is 15. State whether the claim of the principal
is right or not at a 5% significance level.
➢ Our null Hypothesis is H0 = 𝜇 = 100
➢ So, our alternative Hypothesis should be Ha > 100
➢ Level of significance 𝛼 = 0.05
➢ Now For Z-test
𝑋̅ −𝜇 110−100
𝑍= 𝜎 = = 4.71
15/√50
√𝑛
➢ Now Calculating Z critical value from Table, we get 1.645.
As our Z statistical value is higher than Z critical value so we are rejecting Null Hypothesis.
That’s mean we cannot clearly say that the people who study are more intelligent than others.
Python Simulation
For python Simulation we used Numpy library for mathematical operation and scipy library for
Z statistical value calculation.
18
Result:
Result:
19
Conclusion
In hypothesis testing, we evaluate the validity of a hypothesis about a population parameter based
on sample data. After conducting hypothesis testing with a significance level of 5%, we compare
the calculated test statistic to the critical value from the appropriate distribution or calculate the p-
value.
If the test statistic falls in the rejection region (i.e., it is greater than the critical value for a right-
tailed test, less than the critical value for a left-tailed test, or extreme for a two-tailed test), we
reject the null hypothesis in Favor of the alternative hypothesis.
If the p-value is less than the chosen significance level (typically 0.05), we reject the null
hypothesis.
If we reject the null hypothesis, we conclude that there is enough evidence to support the
alternative hypothesis. Otherwise, if we fail to reject the null hypothesis, we do not have enough
evidence to support the alternative hypothesis.
In summary, hypothesis testing provides a systematic framework for making decisions about
population parameters based on sample data, helping us draw reliable conclusions in the face of
uncertainty.
References
1. Hacking, I. Logic of Statistical Inference; Cambridge University Press: Cambridge, UK, 2016.
2. Fisher, R.A. Statistical Methods for Research Workers; Genesis Publishing Pvt Ltd.: Guildford,
UK, 1925.
3. Neyman, J.; Pearson, E.S. On the Problem of the Most Efficient Tests of Statistical
Hypotheses. Philos. Trans. R. Soc. Lond. 1933, 231, 289–337.
4. Lehman, E. Testing Statistical Hypotheses; Springer: New York, NY, USA, 2005.
5. Murdoch, D.J.; Tsai, Y.L.; Adcock, J. p-valuess are random variables. Am. Stat. 2008, 62, 242–
245.
6. Hubbard, R.; Parsa, R.A.; Luthy, M.R. The spread of statistical significance testing in psychology:
The case of the Journal of Applied Psychology, 1917–1994. Theory Psychol. 1997, 7, 545–554
7. Shoptaw, S.; Yang, X.; Rotheram-Fuller, E.J.; Hsieh, Y.C.M.; Kintaudi, P.C.; Charuvastra, V.;
Ling, W. Randomized placebo-controlled trial of baclofen for cocaine dependence: Preliminary
effects for individuals with chronic patterns of cocaine use. J. Clin. Psychiatry 2003, 64, 1440–
1448
20