ForHosting KIT · Developer Utilities

Sample Size for a Mean Calculator

This sample size for a mean calculator finds the minimum number of independent observations needed to estimate a population mean with your chosen absolute margin of error and two-sided confidence level.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Supply the expected population standard deviation in the same units as the margin. The calculator converts confidence to a standard normal critical value, applies the established planning formula, and rounds upward to a whole observation. It is useful for planning measurements, surveys, laboratory studies, and quality-control work before data collection begins.

Choose inputs that describe the planned measurement

Begin with a clearly defined numerical outcome and target population. The margin is the largest acceptable distance between the sample mean and the population mean, expressed in the outcome's original units. If delivery time is measured in minutes and an estimate within two minutes is required, enter a margin of 2. The deviation is the population standard deviation you expect for that same outcome, also in minutes. Estimate it from a pilot study, a reliable earlier study, operational records, or a genuinely comparable population. Using mismatched units makes the calculation meaningless, so do not enter a percentage margin unless the measured outcome itself is a percentage. Confidence is entered as a decimal: for example, 0.95 represents a two-sided 95 percent confidence level. The method assumes independent observations and a stable standard deviation. If the deviation estimate is uncertain, consider calculating several scenarios, including a cautiously larger deviation, because greater variability requires more observations. Define the analysis population, measurement procedure, margin, and deviation source before looking at the result so that convenient inputs do not quietly replace the study's actual requirements.

Understand the formula and upward rounding

The calculator first converts the requested two-sided confidence level into a critical value from the standard normal distribution, commonly called a z-score. It then multiplies that critical value by the expected standard deviation, divides by the target margin, and squares the result. In symbols, the unrounded requirement is the square of z times deviation divided by margin. The final sample size is always rounded upward because a fraction of an observation cannot be collected and ordinary rounding could leave the plan slightly below its declared precision. The displayed z-score is rounded for readability, but the sample-size calculation uses the full internal value. A tighter margin increases the requirement rapidly: halving the margin multiplies the sample size by approximately four when the other inputs stay fixed. A larger deviation or higher confidence also increases the requirement. The output is a planning minimum under the formula's assumptions, not a promise that every realized sample mean will lie within the margin. Confidence describes the long-run coverage of the interval procedure across repeated samples, while the actual result still depends on sampling quality, missing data, and whether the assumed variability represents the population.

Adjust the statistical minimum for real study design

Treat the returned sample size as the number of valid, independent observations required for analysis. It does not automatically include unusable measurements, nonresponse, participant withdrawal, equipment failure, or records removed during cleaning. If only 80 percent of recruited observations are expected to remain valid, divide the required valid count by 0.8 and round upward to plan recruitment. Clustered designs, such as patients within clinics or products within manufacturing batches, often need an additional design-effect adjustment because observations from the same group can be correlated. Repeated measurements on the same subject are not automatically equivalent to the same number of independent subjects. The formula also uses a standard normal critical value and assumes that the standard deviation is known well enough for planning. Very small studies with an estimated standard deviation may need a t-based or iterative method instead. A finite-population correction may reduce the requirement when sampling a substantial share of a small, known population, but it is not applied here. Record every adjustment and its rationale alongside the original statistical minimum. Automated API calculations cost $0.002 per request and return the same deterministic result for identical inputs.

Plan a laboratory measurement study

Determine how many independent specimens are needed to estimate an average concentration within a chosen unit margin.

Design an operations time study

Estimate the observation count required to report a mean handling or delivery time at a stated confidence level.

Prepare a quality-control investigation

Calculate the valid measurement minimum before adding allowances for rejected readings or clustered production batches.

What formula does the calculator use?

It uses the large-population normal planning formula: the square of the two-sided z critical value times standard deviation divided by margin, rounded upward.

Must margin and deviation use the same units?

Yes. If deviation is measured in kilograms, the margin must also be in kilograms. Mixing units produces an invalid study plan.

Where should the deviation estimate come from?

Use a pilot sample, a credible previous study, operational history, or a comparable population. When uncertain, test a larger deviation as a conservative scenario.

Does the result include nonresponse or unusable data?

No. It is the minimum valid independent observation count. Increase recruitment separately for expected nonresponse, exclusions, attrition, or measurement failures.

Does this apply a finite-population correction?

No. It returns the conventional large-population result. Apply a finite-population correction separately when sampling a substantial fraction of a known population.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/stat/sample-size-mean

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/stat/sample-size-mean \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"margin":2,"deviation":10,"confidence":0.95}'
{
  "margin": 2,
  "deviation": 10,
  "confidence": 0.95
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "stat.sample_size_mean",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →