Calculate the sample proportion (p-hat), standard error, confidence intervals (Wald and Wilson), margin of error, and required sample sizes.
The P-Hat Calculator computes the sample proportion (p̂ = x/n) and its associated statistics including standard error, confidence intervals, margin of error, and hypothesis test z-statistics. It provides both the traditional Wald interval and the more accurate Wilson score interval for confidence interval estimation.
Sample proportions are one of the most commonly estimated parameters in statistics. Whenever you survey a group and record the fraction with some characteristic — voter preference, defect rate, treatment success, click-through rate — you're working with p-hat. This calculator handles the full workflow: from computing the point estimate through constructing confidence intervals to performing hypothesis tests against a specified null proportion.
The tool also includes a sample size planning table that shows how many observations you'd need to achieve different margin-of-error targets at your current confidence level. This forward-looking feature is invaluable for designing surveys, clinical trials, and quality inspections before collecting data. Check the example with realistic values before reporting.
Surveys, polls, clinical trials, A/B tests, quality control inspections, and election forecasts all rely on sample proportions. Calculating p-hat and its confidence interval correctly is essential for drawing valid conclusions from sample data. Getting these calculations wrong can lead to overconfident claims or missed insights.
This calculator provides both Wald and Wilson intervals because the standard Wald method — while simpler — often gives intervals with coverage below the nominal level, especially for extreme proportions. The Wilson interval is recommended by statisticians as the default choice, and having both methods side by side helps you understand when the simpler method is adequate.
p̂ = x/n. SE = √(p̂(1-p̂)/n). Wald CI: p̂ ± z* × SE. Wilson CI: (x + z²/2) / (n + z²) ± z/(n + z²) × √(x(n-x)/n + z²/4). Z-test: z = (p̂ - p₀) / √(p₀(1-p₀)/n).
Result: p̂ = 0.6, 95% CI [0.5696, 0.6304], z = 6.32
With 600 successes in 1000 trials, p̂ = 0.6. The standard error is 0.0155, giving a 95% Wald CI of [0.5696, 0.6304]. Testing against p₀ = 0.5 yields z = 6.32, strongly rejecting the null.
A sample proportion is the simplest and most intuitive estimator in statistics. You count successes, divide by the total, and get an estimate of the population parameter. Despite its simplicity, the statistics surrounding p-hat — standard errors, confidence intervals, and hypothesis tests — require careful computation because the binomial distribution has special properties that affect interval accuracy.
The sampling distribution of p-hat is approximately normal when np and nq are both at least 5 (by the Central Limit Theorem). This normality enables z-based inference, but the approximation quality varies with the true proportion and sample size.
The Wald interval (p̂ ± z√(p̂q̂/n)) is the formula most textbooks teach first. It's intuitive and easy to compute, but it has well-documented problems: actual coverage can be substantially below the nominal level, it can produce intervals outside [0,1], and it collapses to a point when p̂ = 0 or p̂ = 1. The Wilson interval corrects these issues by inverting the hypothesis test rather than plugging in the estimate.
Research by Agresti and Coull (1998) showed that even the simple "add 2 successes and 2 failures" adjustment dramatically improves the Wald interval. The Wilson interval goes further, providing reliable coverage across all values of p and n.
Before collecting data, researchers use the margin-of-error formula to determine the required sample size: n = (z²p̂q̂)/E², where E is the desired MOE. Since the true p is unknown before sampling, it's common to use p = 0.5 (worst case, yielding the largest n) or a pilot estimate. The sample size table in this calculator uses your current p̂ as the planning estimate, giving realistic projections for future studies.
P-hat (p̂) is the sample proportion — the number of successes divided by the sample size (x/n). It's an estimate of the true population proportion p. For example, if 600 out of 1000 surveyed people prefer Brand A, p̂ = 0.6.
The Wald interval (p̂ ± z*SE) is simpler but can give poor coverage when p is near 0 or 1 or when n is small. The Wilson interval adjusts for these issues and is generally recommended, especially when p̂ < 0.05, p̂ > 0.95, or n < 40.
A 95% confidence interval means that if you repeated the sampling process many times, about 95% of the resulting intervals would contain the true proportion. It's NOT the probability that p is in this specific interval.
Use the sample size table in the results. For a ±3% margin of error at 95% confidence, you typically need around 1,000 observations. For ±1%, you need roughly 10,000. The exact number depends on the true proportion.
Use the z-test when you have a hypothesized proportion and want to test whether your sample data provides evidence against it. Requirements: np₀ ≥ 5 and n(1-p₀) ≥ 5 for the normal approximation to be valid.
The margin of error (MOE) is half the width of the confidence interval. When a poll says "60% ± 3%," the MOE is 3 percentage points, meaning the true proportion is likely between 57% and 63%.