(Basic Statistics for Citizen Data Scientist)
Comparing two means when variances are known
Theorem 1: Let x̄ and ȳ be the means of two samples of size nx and ny respectively. If x and y are normal or nx and ny are sufficiently large for the Central Limit Theorem to hold, then x̄ – ȳ has normal distribution with mean μx – μy and standard deviation
Proof: Since the samples are random, x̄ and ȳ are normally and independently distributed. By the Central Limit Theorem and Property 1 and 2 of Basic Characteristics of the Normal Distribution, we know that x̄ – ȳ is normally distributed with mean
and standard deviation
Hypothesis Testing: When the population is normal or the sample sizes are sufficiently large, we can use the above theorem to compare two population means. The theorem requires that the population standard deviations be known, which is usually not the case. Often, especially with large samples, the standard deviation of the samples can be used as an approximation for the population standard deviations. We can also employ the t-test which doesn’t require that the variances be known, and is especially useful when the sample sizes are small.
Excel Tools: Excel provides a data analysis tool called z-Test: Two Sample for Means to automate the hypothesis testing process (as shown in Example 1).
Example 1: The average height of 5 year old boys in a certain country is known to be normally distributed with mean 95 cm and standard deviation 16 cm. A firm is selling a nutrient which it claims will significantly increase the height of children. In order to demonstrate its claim it selects a random sample of 60 four year old boys, half of whom are given the nutrient for one year and half of whom are not. Given that the heights of the boys at 5 years of age are as in the Figure 1, determine whether the nutrient is effective in increasing height.
Figure 1 – Two sample test using z-scores
In addition to the raw data, Figure 1 shows how to calculate the z-score for the difference between the sample means based on a normal population with a known standard deviation of 16 (i.e. a known variance of 162 = 256). Here the null hypothesis H0 is
This is a two-tail test, which is why the p-value (in cell I12) is doubled. Since p-value = .008 < .05 = α, we reject the null hypothesis, and conclude there is a significant difference between the boys that take the nutrients and those that don’t.
We can also use Excel’s data analysis tool to automatically calculate the z-score from the sample data (although we must first reorganize the data in the form of either a single row or single column). Figure 2 shows the output of the data analysis tool for Example 1.
Figure 2 – Output of z-Test: Two Sample for Means data analysis tool
Looking at the two-tail results, we see once again that .008 < .05 (or alternatively |z| = 2.65 > 1.96 = z-crit), and so we reject the null hypothesis.
Summarise Data in R – How to know dimention of a dataset in R
Statistics for Beginners in Excel – Comparing two means when variances are known
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.
Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners
Latest end-to-end Learn by Coding Projects (Jupyter Notebooks) in Python and R:
All Notebooks in One Bundle: Data Science Recipes and Examples in Python & R.
End-to-End Python Machine Learning Recipes & Examples.
End-to-End R Machine Learning Recipes & Examples.
Applied Statistics with R for Beginners and Business Professionals
Data Science and Machine Learning Projects in Python: Tabular Data Analytics
Data Science and Machine Learning Projects in R: Tabular Data Analytics
Python Machine Learning & Data Science Recipes: Learn by Coding
R Machine Learning & Data Science Recipes: Learn by Coding
Comparing Different Machine Learning Algorithms in Python for Classification (FREE)
There are 2000+ End-to-End Python & R Notebooks are available to build Professional Portfolio as a Data Scientist and/or Machine Learning Specialist. All Notebooks are only $29.95. We would like to request you to have a look at the website for FREE the end-to-end notebooks, and then decide whether you would like to purchase or not.