P-Hat Calculator

Calculate the sample proportion (p-hat), standard error, confidence intervals (Wald and Wilson), margin of error, and required sample sizes.

P-Hat (Sample Proportion) Calculator

For hypothesis testing
p̂ (Sample Proportion)
0.600000
600 successes out of 1000 trials
q̂ (1 - p̂)
0.400000
Complement of sample proportion
Standard Error
0.015492
SE = √(p̂q̂/n) = √(0.240000/1000)
Margin of Error
0.030364
z* × SE = 1.9600 × 0.015492
Wald CI
[0.5696, 0.6304]
95% confidence interval (Wald method)
Wilson CI
[0.5693, 0.6299]
Wilson score interval (more accurate for small n)
Z-Statistic
6.3246
(p̂ - p₀)/SE₀ = (0.6000 - 0.5)/0.015811
z* Critical
1.9600
Critical value for 95% confidence
Proportion Visualization:
p̂ = 60.0%
q̂ = 40.0%

Confidence Intervals at Different Levels

Levelz*LowerUpperWidth
90%1.64490.57450.62550.0510
95%1.96000.56960.63040.0607
99%2.57580.56010.63990.0798
99.9%3.29050.54900.65100.1020

Required Sample Size for Target MOE

Target MOE±%Required nCurrent MOE Ratio
±0.01±1.0%9,220
±0.02±2.0%2,305
±0.03±3.0%1,025
±0.05±5.0%369
±0.10±10.0%93
Planning notes, formulas, and examples

About the P-Hat Calculator

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.

When This Page Helps

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.

It gives 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.

How to Use the Inputs

  1. Enter the number of successes (x) observed in your sample.
  2. Enter the total sample size (n).
  3. Select your desired confidence level (90%, 95%, 99%, or 99.9%).
  4. For hypothesis testing, enter the hypothesized proportion (p₀) and choose the alternative hypothesis direction.
  5. Review p-hat, standard error, margin of error, and both confidence intervals.
  6. Check the confidence interval comparison table across different levels.
  7. Use the sample size table to plan future studies with tighter margins.
Formula used
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).

Example Calculation

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.

Tips & Best Practices

  • Use the Wilson interval when p̂ is near 0 or 1, or when your sample is small (n < 40).
  • The sample size table helps you plan — check it before conducting your survey.
  • For proportions near 50%, you need the largest sample size for a given MOE.
  • Higher confidence levels require wider intervals — there's always a tradeoff.
  • The z-statistic tells you how many standard errors p̂ is from p₀ — values beyond ±1.96 are significant at the 5% level.
  • If the confidence interval doesn't contain p₀, the hypothesis test will reject H₀.

Understanding Sample Proportions

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.

Wald vs. Wilson Confidence Intervals

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.

Planning Sample Sizes

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.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • 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.