maths.free › Statistics & Probability › Comparing two samples
Comparing two samples
Differences of means and proportions, and paired samples.
To compare two groups, test the difference of their means (or proportions). The standard error of a difference combines both samples' spreads: √(s₁²/n₁ + s₂²/n₂). Paired data — the same subjects measured twice — reduce to a one-sample test on the differences.
Two Population Means with Unknown Standard Deviations
- The two independent samples are simple random samples from two distinct populations.
- For the two distinct populations
- if the sample sizes are small, the distributions are important (should be normal), and
- if the sample sizes are large, the distributions are not important (need not be normal)
The comparison of two population means is very common. A difference between the two samples depends on both the means and the standard deviations. Very different means can occur by chance if there is great variation among the individual samples. To account for the variation, we take the difference of the sample means, \({\overset{\bar}{X}}_{1}-{\overset{\bar}{X}}_{2}\), and divide by the standard error to standardize the difference. The result is a t-score test statistic.
Because we do not know the population standard deviations, we estimate them using the two sample standard deviations from our independent samples. For the hypothesis test, we calculate the estimated standard deviation, or standard error, of the difference in sample means, \({\overset{\bar}{X}}_{1}-{\overset{\bar}{X}}_{2}\text{.}\)
The standard error is calculated as follows:
\[\sqrt{\frac{({s}_{1}{)}^{2}}{{n}_{1}}+\frac{({s}_{2}{)}^{2}}{{n}_{2}}}\]The test statistic (t-score) is calculated as follows: \[\frac{\text{(}{\overset{\bar}{x}}_{1}-{\overset{\bar}{x}}_{2}\text{)}-\text{(}{\mu }_{1}-{\mu }_{2}\text{)}}{\sqrt{\frac{{\text{(}{s}_{1}\text{)}}^{2}}{{n}_{1}}+\frac{{\text{(}{s}_{2}\text{)}}^{2}}{{n}_{2}}}}\]
- s1 and s2, the sample standard deviations, are estimates of σ1 and σ2, respectively,
- σ1 and σ1 are the unknown population standard deviations,
- \({\overset{\bar}{x}}_{1}\) and \({\overset{\bar}{x}}_{2}\) are the sample means, and
- μ1 and μ2 are the population means.
The number of degrees of freedom (df) requires a somewhat complicated calculation. However, a computer or calculator calculates it easily. The df are not always a whole number. The test statistic calculated previously is approximated by the Student’s t-distribution with df as follows:
Degrees of freedom
\[df=\frac{{(\frac{{({s}_{1})}^{2}}{{n}_{1}}+\frac{{({s}_{2})}^{2}}{{n}_{2}})}^{2}}{(\frac{1}{{n}_{1}-1}){(\frac{{({s}_{1})}^{2}}{{n}_{1}})}^{2}+(\frac{1}{{n}_{2}-1}){(\frac{{({s}_{2})}^{2}}{{n}_{2}})}^{2}}\]| Size of Effect | d |
| Small | 0.2 |
| medium | 0.5 |
| Large | 0.8 |
Condensed — the full section is in OpenStax Statistics.
Two Population Means with Unknown Standard Deviations
Use the following information to answer the next 15 exercises. Indicate if the hypothesis test is for
- independent group means, population standard deviations, and/or variances known,
- independent group means, population standard deviations, and/or variances unknown,
- matched or paired samples,
- single mean,
- two proportions, or
- single proportion.
Use the following information to answer the next three exercises: A study is done to determine which of two soft drinks has more sugar. There are 13 cans of Beverage A in a sample and six cans of Beverage B. The mean amount of sugar in Beverage A is 36 grams with a standard deviation of 0.6 grams. The mean amount of sugar in Beverage B is 38 grams with a standard deviation of 0.8 grams. The researchers believe that Beverage B has more sugar than Beverage A, on average. Both populations have normal distributions.
Use the following information to answer the next 12 exercises. The U.S. Centers for Disease Control reports that the mean life expectancy was 47.6 years for whites born in 1900 and 33.0 years for nonwhites. Suppose that you randomly survey death records for people born in 1900 in a certain county. Of the 124 whites, the mean life span was 45.3 years with a standard deviation of 12.7 years. Of the 82 nonwhites, the mean life span was 34.1 years with a standard deviation of 15.6 years. Conduct a hypothesis test to see if the mean life spans in the county were the same for whites and nonwhites.
Two Population Means with Known Standard Deviations
Even though this situation is not likely (knowing the population standard deviations), the following example illustrates hypothesis testing for independent means, known population standard deviations. The sampling distribution for the difference between the means is normal, and both populations must be normal. The random variable is
\({\overset{\bar}{X}}_{1}-{\overset{\bar}{X}}_{2}\). The normal distribution has the following format:
Normal distribution is
\[{\overset{\bar}{X}}_{1}-{\overset{\bar}{X}}_{2}\sim N[{\mu }_{1}-{\mu }_{2},\sqrt{\frac{{({\sigma }_{1})}^{2}}{{n}_{1}}+\frac{{({\sigma }_{2})}^{2}}{{n}_{2}}}].\]
Condensed — the full section is in OpenStax Statistics.
Two Population Means with Known Standard Deviations
Use the following information to answer the next five exercises. The mean speeds of fastball pitches from two different baseball pitchers are to be compared. A sample of 14 fastball pitches is measured from each pitcher. The populations have normal distributions. shows the result. Scouters believe that Rodriguez pitches a speedier fastball.
| Pitcher | Sample Mean Speed of Pitches (mph) | Population Standard Deviation |
| Wesley | 86 | 3 |
| Rodriguez | 91 | 7 |
Use the following information to answer the next five exercises. A researcher is testing the effects of plant food on plant growth. Nine plants have been given the plant food. Another nine plants have not been given the plant food. The heights of the plants are recorded after eight weeks. The populations have normal distributions. The following table is the result. The researcher thinks the food makes the plants grow taller.
| Plant Group | Sample Mean Height of Plants (inches) | Population Standard Deviation |
| Food | 16 | 2.5 |
| No food | 14 | 1.5 |
Use the following information to answer the next five exercises. Two metal alloys are being considered as material for ball bearings. The mean melting point of the two alloys is to be compared. Fifteen pieces of each metal are being tested. Both populations have normal distributions. The following table is the result. It is believed that Alloy Zeta has a different melting point.
| Sample Mean Melting Temperatures (°F) | Population Standard Deviation | |
| Alloy Gamma | 800 | 95 |
| Alloy Zeta | 900 | 105 |
Comparing Two Independent Population Proportions
When conducting a hypothesis test that compares two independent population proportions, the following characteristics should be present:
- The two independent samples are simple random samples that are independent.
- The number of successes is at least five, and the number of failures is at least five, for each of the samples.
- Growing literature states that the population must be at least 10 or 20 times the size of the sample. This keeps each population from being over-sampled and causing incorrect results.
Comparing two proportions, like comparing two means, is common. If two estimated proportions are different, it may be due to a difference in the populations or it may be due to chance. A hypothesis test can help determine if a difference in the estimated proportions reflects a difference in the population proportions.
The difference of two proportions follows an approximate normal distribution. Generally, the null hypothesis states that the two proportions are the same. That is, H0: pA = pB. To conduct the test, we use a pooled proportion, pc.
The pooled proportion is calculated as follows:
\[{p}_{c}=\frac{{x}_{A}+{x}_{B}}{{n}_{A}+{n}_{B}}\text{.}\]The distribution for the differences is
\[{{P}^{'}}_{A}-{{P}^{'}}_{B}\sim N[0,\sqrt{{p}_{c}(1-{p}_{c})(\frac{1}{{n}_{A}}+\frac{1}{{n}_{B}})}].\]The test statistic (z-score) is
\[z=\frac{({{p}^{'}}_{A}-{{p}^{'}}_{B})-({p}_{A}-{p}_{B})}{\sqrt{{p}_{c}(1-{p}_{c})(\frac{1}{{n}_{A}}+\frac{1}{{n}_{B}})}}.\]Condensed — the full section is in OpenStax Statistics.
Comparing Two Independent Population Proportions
Use the following information for the next five exercises. Two types of phone operating system are being tested to determine if there is a difference in the proportions of system failures (crashes). Fifteen out of a random sample of 150 phones with OS1 had system failures within the first eight hours of operation. Nine out of another random sample of 150 phones with OS2 had system failures within the first eight hours of operation. OS2 is believed to be more stable (have fewer crashes) than OS1.
Use the following information to answer the next 12 exercises. In the recent U.S. Census, 3 percent of the U.S. population reported being of two or more races. However, the percent varies tremendously from state to state. Suppose that two random surveys are conducted. In the first random survey, out of 1,000 North Dakotans, only 9 people reported being of two or more races. In the second random survey, out of 500 Nevadans, 17 people reported being of two or more races. Conduct a hypothesis test to determine if the population percents are the same for the two states or if the percent for Nevada is statistically higher than for North Dakota.
Matched or Paired Samples (Optional)
When using a hypothesis test for matched or paired samples, the following characteristics should be present:
- Simple random sampling is used.
- Sample sizes are often small.
- Two measurements (samples) are drawn from the same pair of individuals or objects.
- Differences are calculated from the matched or paired samples.
- The differences form the sample that is used for the hypothesis test.
- Either the matched pairs have differences that come from a population that is normal or the number of differences is sufficiently large so that distribution of the sample mean of differences is approximately normal.
In a hypothesis test for matched or paired samples, subjects are matched in pairs and differences are calculated. The differences are the data. The population mean for the differences, μd, is then tested using a Student’s-t test for a single population mean with n – 1 degrees of freedom, where n is the number of differences.
The test statistic (t-score) is
\[t=\frac{{\overset{\bar}{x}}_{d}-{\mu }_{d}}{(\frac{{s}_{d}}{\sqrt{n}})}\text{.}\]Condensed — the full section is in OpenStax Statistics.
Matched or Paired Samples (Optional)
Use the following information to answer the next five exercises. A study was conducted to test the effectiveness of a software patch in reducing system failures over a six-month period. Results for randomly selected installations are shown in . The before value is matched to an after value, and the differences are calculated. The differences have a normal distribution. Test at the 1 percent significance level.
| Installation | A | B | C | D | E | F | G | H |
| Before | 3 | 6 | 4 | 2 | 5 | 8 | 2 | 6 |
| After | 1 | 5 | 2 | 0 | 1 | 0 | 2 | 2 |
Use the following information to answer next five exercises. A study was conducted to test the effectiveness of a juggling class. Before the class started, six subjects juggled as many balls as they could at once. After the class, the same six subjects juggled as many balls as they could. The differences in the number of balls are calculated. The differences have a normal distribution. Test at the 1 percent significance level.
| Subject | A | B | C | D | E | F |
| Before | 3 | 4 | 3 | 2 | 4 | 5 |
| After | 4 | 5 | 6 | 4 | 5 | 7 |
Use the following information to answer the next five exercises. A doctor wants to know if a blood pressure medication is effective. Six subjects have their blood pressures recorded. After twelve weeks on the medication, the same six subjects have their blood pressure recorded again. For this test, only systolic pressure is of concern. Test at the 1 percent significance level.
| Patient | A | B | C | D | E | F |
| Before | 161 | 162 | 165 | 162 | 166 | 171 |
| After | 158 | 159 | 166 | 160 | 167 | 169 |
Exemplo trabalhado: sqrt(4^2/20 + 3^2/25)
Passo a passo
- \sqrt{\frac{3^{2}}{25} + \frac{4^{2}}{20}} = \sqrt{\frac{3^{2}}{25} + \frac{4}{5}}
Power: 4^{2} = 16.
- \sqrt{\frac{3^{2}}{25} + \frac{4}{5}} = \frac{\sqrt{29}}{5}
Power: 3^{2} = 9.
Revelar a resposta
Practice (40)
Try each one on paper first. Reveal the answer to check; verified ones can be opened in the solver for every step.
-
Is there a difference in the mean amount of time boys and girls aged 7 to 11 play sports each day? Test at the 5 percent level of significance.
Revelar a resposta
The population standard deviations are not known. Let g be the subscript for girls and b be the subscript for boys. Then, μg is the population mean for girls and μb is the population mean for boys. This is a test of two independent groups, two population means.
Random variable: \({\overset{\bar}{X}}_{g}-{\overset{\bar}{X}}_{b}\) = difference in the sample mean amount of time girls and boys play sports each day.
H0: μg = μb H0: μg – μb = 0
Ha: μg ≠ μb Ha: μg – μb ≠ 0
The words the same tell you H0 has an "=". Since there are no other words to indicate Ha, assume it says is different. This is a two-tailed test.Distribution for the test: Use tdf where df is calculated using the df formula for independent groups, two population means. Using a calculator, df is approximately 18.8462. Do not pool the variances.
Calculate the p-value using a Student’s t-distribution: p-value = 0.0054
Graph:
\({s}_{g}=0.866\)
\({s}_{b}=1\)
So, \({\overset{\bar}{x}}_{g}-{\overset{\bar}{x}}_{b}\) = 2 – 3.2 = –1.2
Half the p-value is below –1.2, and half is above 1.2.Make a decision: Since α > p-value, reject H0. This means you reject μg = μb. The means are different.
Conclusion: At the 5 percent level of significance, the sample data show there is sufficient evidence to conclude that the mean number of hours that girls and boys aged 7 to 11 play sports per day is different (mean number of hours boys aged 7 to 11 play sports per day is greater than the mean number of hours played by girls OR the mean number of hours girls aged 7 to 11 play sports per day is greater than the mean number of hours played by boys).
-
Two samples are shown in . Both have normal distributions. The means for the two populations are thought to be the same. Is there a difference in the means? Test at the 5 percent level of significance.
Sample Size Sample Mean Sample Standard Deviation Population A 25 5 1 Population B 16 4.7 1.2 Revelar a resposta
The p-value is 0.4125, which is much higher than 0.05, so we decline to reject the null hypothesis. There is not sufficient evidence to conclude that the means of the two populations are not the same.
-
a. Is this a test of two means or two proportions?
Revelar a resposta
a. two means
-
b. Are the populations standard deviations known or unknown?
Revelar a resposta
b. unknown
-
c. Which distribution do you use to perform the test?
Revelar a resposta
c. Student’s t
-
d. What is the random variable?
Revelar a resposta
d. \({\overset{\bar}{X}}_{A}-{\overset{\bar}{X}}_{B}\)
-
e. What are the null and alternate hypotheses? Write the null and alternate hypotheses in symbols.
Revelar a resposta
e. \({H}_{o}:{\mu }_{A}\le {\mu }_{B}\)
\({H}_{a}:{\mu }_{A}>{\mu }_{B}\) -
f. Is this test right-, left-, or two-tailed?
Revelar a resposta
f.
right -
g. What is the p-value?
Revelar a resposta
g. 0.1928
-
h. Do you reject or not reject the null hypothesis?
Revelar a resposta
h. do not reject
-
i. Conclusion:
Revelar a resposta
i. At the 1 percent level of significance, from the sample data, there is not sufficient evidence to conclude that a student who graduates from College A has taken more math classes, on average, than a student who graduates from College B.
-
A study is done to determine if Company A retains its workers longer than Company B. Company A samples 15 workers, and their average time with the company is 5 years with a standard deviation of 1.2. Company B samples 20 workers, and their average time with the company is 4.5 years with a standard deviation of 0.8. The populations are normally distributed.
- Are the population standard deviations known?
- Conduct an appropriate hypothesis test. At the 5 percent significance level, what is your conclusion?
Revelar a resposta
- They are unknown.
- The p-value = 0.0878. At the 5 percent level of significance, there is insufficient evidence to conclude that the workers of Company A stay longer with the company.
-
Calculate Cohen’s d for . Is the size of the effect small, medium, or large? Explain what the size of the effect means for this problem.
Revelar a resposta
μ1 = 4 s1 = 1.5 n1 = 11
μ2 = 3.5 s2 = 1 n2 = 9
d = 0.384
The effect is small because 0.384 is between Cohen’s value of 0.2 for small effect size and 0.5 for medium effect size. The size of the differences of the means for the two colleges is small, indicating that there is not a significant difference between them. -
Calculate Cohen’s d for . Is the size of the effect small, medium, or large? Explain what the size of the effect means for this problem.
Revelar a resposta
d = 0.834; large, because 0.834 is greater than Cohen’s 0.8 for a large effect size. The size of the differences between the means of the final exam scores of online students and students in a face-to-face class is large, indicating a significant difference.
-
Is there a difference in the weighted alpha of the top 30 stocks of banks in the Northeast and in the West? Test at a 5 percent significance level. Answer the following questions:
- Is this a test of two means or two proportions?
- Are the population standard deviations known or unknown?
- Which distribution do you use to perform the test?
- What is the random variable?
- What are the null and alternative hypotheses? Write the null and alternative hypotheses in words and in symbols.
- Is this test right-, left-, or two-tailed?
- What is the p-value?
- Do you reject or not reject the null hypothesis?
- At the _____ level of significance, from the sample data, there ______ (is/is not) sufficient evidence to conclude that ______.
- Calculate Cohen’s d and interpret it.
Revelar a resposta
- two means
- unknown
- Student’s-t
- \({\overset{\bar}{X}}_{1}\text{ - }{\overset{\bar}{X}}_{2}\)
- H0 : μ1 = μ2, null hypothesis: the means of the weighted alphas are equal.
- Ha : μ1 ≠ μ2, alternative hypothesis: the means of the weighted alphas are not equal.
- two-tailed
- p-value = 0.8787
- Do not reject the null hypothesis.
- This indicates that the trends in stocks are about the same in the top 30 banks in each region. 5% level of significance, from the sample data, there is not sufficient evidence to conclude that the mean weighted alphas for the banks in the northeast and the west are different
- d = 0.040; very small, because 0.040 is less than Cohen’s value of 0.2 for small effect size. The size of the difference of the means of the weighted alphas for the two regions of banks is small indicating that there is not a significant difference between their trends in stocks.
-
It is believed that 70 percent of males pass their drivers test in the first attempt, while 65 percent of females pass the test in the first attempt. Of interest is whether the proportions are equal.
Revelar a resposta
two proportions
-
A new laundry detergent is tested on consumers. Of interest is the proportion of consumers who prefer the new brand over the leading competitor. A study is done to test this.
-
A new windshield treatment claims to repel water more effectively. Ten windshields are tested by simulating rain without the new treatment. The same windshields are then treated, and the experiment is run again. A hypothesis test is conducted.
Revelar a resposta
matched or paired samples
-
The known standard deviation in salary for all mid-level professionals in the financial industry is $11,000. Company A and Company B are in the financial industry. Suppose samples are taken of mid-level professionals from Company A and from Company B. The sample mean salary for mid-level professionals in Company A is $80,000. The sample mean salary for mid-level professionals in Company B is $96,000. Company A and Company B management want to know if their mid-level professionals are paid differently, on average.
-
The average worker in Germany gets eight weeks of paid vacation.
Revelar a resposta
single mean
-
According to a television commercial, 80% of dentists agree that a brand of fluoridated toothpaste is the best on the market.
-
It is believed that the average grade on an English essay in a particular school system is higher for females than for males. A random sample of 31 females had a mean score of 82 with a standard deviation of 3, and a random sample of 25 males had a mean score of 76 with a standard deviation of 4.
Revelar a resposta
independent group means, population standard deviations and/or variances unknown
-
The league mean batting average is 0.280 with a known standard deviation of 0.06. The Rattlers and the Vikings belong to the league. The mean batting average for a sample of eight Rattlers is 0.210, and the mean batting average for a sample of eight Vikings is 0.260. There are 24 players on the Rattlers and 19 players on the Vikings. Are the batting averages of the Rattlers and Vikings statistically different?
-
In a random sample of 100 forests in the United States, 56 were coniferous or contained conifers. In a random sample of 80 forests in Mexico, 40 were coniferous or contained conifers. Is the proportion of conifers in the United States statistically more than the proportion of conifers in Mexico?
Revelar a resposta
two proportions
-
A new medicine is said to help improve sleep. Eight subjects are picked at random and given the medicine. The mean hours slept for each person were recorded before starting the medication and after.
-
It is thought that teenagers sleep more than adults on average. A study is done to verify this. A sample of 16 teenagers has a mean of 8.9 hours slept and a standard deviation of 1.2. A sample of 12 adults has a mean of 6.9 hours slept and a standard deviation of 0.6.
Revelar a resposta
independent group means, population standard deviations and/or variances unknown
-
Varsity athletes practice five times a week, on average.
-
A sample of 12 in-state graduate school programs at School A has a mean tuition of $64,000 with a standard deviation of $8,000. At School B, a sample of 16 in-state graduate programs has a mean tuition of $80,000 with a standard deviation of $6,000. On average, are the mean tuitions different?
Revelar a resposta
independent group means, population standard deviations and/or variances unknown
-
A new WiFi range booster is being offered to consumers. A researcher tests the native range of 12 different routers under the same conditions. The ranges are recorded. Then, the researcher uses the new WiFi range booster and records the new ranges. Does the new WiFi range booster do a better job?
-
A high school principal claims that 30 percent of student athletes drive themselves to school, while 4 percent of nonathletes drive themselves to school. In a sample of 20 student athletes, 45 percent drive themselves to school. In a sample of 35 nonathlete students, 6 percent drive themselves to school. Is the percent of student athletes who drive themselves to school more than the percent of nonathletes?
Revelar a resposta
two proportions
-
Are standard deviations known or unknown?
-
What is the random variable?
Revelar a resposta
The random variable is the difference between the mean amounts of sugar in the two soft drinks.
-
Is this a one-tailed or two-tailed test?
-
Is this a test of means or proportions?
Revelar a resposta
means
-
State the null and alternative hypotheses.
- H0: __________
- Ha: __________
-
Is this a right-tailed, left-tailed, or two-tailed test?
Revelar a resposta
two-tailed
-
In symbols, what is the random variable of interest for this test?
-
In words, define the random variable of interest for this test.
Revelar a resposta
the difference between the mean life spans of whites and nonwhites
-
Which distribution (normal or Student’s t) would you use for this hypothesis test?
-
Explain why you chose the distribution you did for .
Revelar a resposta
This is a comparison of two population means with unknown population standard deviations.
Tente o seu próprio
Parts of this page are adapted from OpenStax Statistics (CC BY 4.0). Condensed and re-explained here; errors are ours.
Mais em Statistics & Probability
Sampling and dataDescribing data with graphsMean, median and modeProbabilityCounting: permutations and combinationsDiscrete random variablesContinuous random variablesThe normal distributionThe central limit theoremConfidence intervalsHypothesis testingChi-square testsLinear regression and correlationANOVA and the F distribution