Sample Size Calculation - Means

This Demonstration calculates the minimum sample size, , required to be randomly drawn from a population, to be able to detect a difference in the population mean of at least units from the true population mean with confidence of . You can vary (the Type I risk), (the Type II risk), or , the ratio of the detected difference to the population standard deviation. In most practical cases, the standard deviation may not actually be known, but is estimated from prior knowledge or experience.



  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


Suppose an experiment is to be conducted where a treatment of some sort is to be applied to a population. The investigator is interested in knowing the minimum sample size that should be randomly selected from the population to detect a change in the mean of the population as a result of the treatment. The statistical factors that influence the sample size are:
- the value selected for , the Type I risk (the risk of rejecting a true null hypothesis, )
- the value selected for , the Type II risk (the risk of accepting the null hypothesis, , as true when, in reality, it is false)
- the value of the population standard deviation, σ (this is often an estimate, based on judgement and experience)
- the size (relative to σ) of the effect to be detected by the sample
The Type I risk is that of getting a false positive from the sample. In other words, there is a probability of that the sample will indicate that there is a difference of at least when, in fact, there is not.
The Type II risk is that of getting a false negative from the sample. In other words, there is a probability of that the sample will indicate there is not a difference of at least when, in fact, there is such a difference. The ability to detect a difference when there actually is one is called the power of the test and is equal to .
Additionally, whether the test of the hypothesis is a one-sided or two-sided test has an effect on the sample size. A one-sided test would, for example, look at whether there is an increase OR a decrease in the mean (not both), whereas a two-sided test would consider whether the mean is EITHER more than or less than the value in the null hypothesis.
When using this Demonstration, you should mentally formulate a null hypothesis and an alternative hypothesis (either one- or two-sided). Then the appropriate control selections can be made and the resulting sample sizes can be examined.
Typical values for and are 0.05 and 0.20, respectively, resulting in a confidence of 95% and a test power of 80%.
Note that looking for a small difference, , drives a large sample size, as would be expected.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2018 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+