Calculate p-hat (p̂), the sample proportion x/n, from the number of successes and the sample size, with its standard error, confidence interval or z-test.
- All Statistics Calculators
- Conditional Probability Calculator
- Compound Probability Calculator
- Expected Frequency Calculator
- Empirical Probability Calculator
- Y-Hat Calculator
Calculator Functions
| Function | What it does | What it requires |
|---|---|---|
| Sample proportion | Finds p-hat (p̂) as a decimal from the number of successes in a sample | Requires the successes (x) and the sample size (n), both whole numbers |
| Success count | Finds the number of successes behind a known p-hat | Requires the sample proportion (0 to 1) and the sample size |
| Sample size from counts | Finds the sample size that turns a success count into a known p-hat | Requires the successes and a sample proportion above 0 |
| Confidence interval · counts | Finds a Wilson score or Wald interval for the population proportion from raw counts | Requires the successes, the sample size, a confidence level of 90%, 95% or 99%, and the interval method |
| Confidence interval · proportion | Finds the same interval when p-hat is already known | Requires the sample proportion, the sample size, the confidence level and the interval method |
| One-proportion z-test · counts | Finds the z statistic and approximate p-value for a test of p-hat against a claimed proportion | Requires the successes, the sample size, a null proportion between 0 and 1, the alternative hypothesis and a significance level of 10%, 5% or 1% |
| One-proportion z-test · proportion | Runs the same test when p-hat is already known | Requires the sample proportion, the sample size, the null proportion, the alternative hypothesis and the significance level |
| Required sample size | Finds how many observations give a chosen margin of error for a proportion | Requires the confidence level and the margin in percentage points. The expected proportion (blank counts as 50%) and a finite population size are optional |
The first three functions also show p-hat as a percentage, the complement q̂ = 1 − p̂ and the estimated standard error. Both interval functions add the interval center and half-width, and both z-test functions add the z statistic, the null standard error and a reject or do not reject decision at the chosen significance level.
P-Hat Formulas
| p̂ | Sample proportion, a decimal from 0 to 1 |
| x | Number of successes: the items in the sample that have the characteristic being counted |
| n | Sample size: the total number of items observed |
Sample proportion
The successes are divided by the sample size, so 26 successes in a sample of 200 give p̂ = 26 ÷ 200 = 0.13 [1]. A success count larger than the sample size is rejected. The estimated standard error shown with the result is:
For p̂ = 0.13 and n = 200 the standard error is √(0.13 × 0.87 ÷ 200) = 0.0238.
Success count
A proportion of 0.13 in a sample of 200 means 26 successes. The product has to be a whole number, because a count of 25.5 items cannot exist. A rounded proportion such as 0.33 with n = 30 gives 9.9 and is rejected.
Sample size from counts
With 26 successes and p̂ = 0.13 the sample size is 26 ÷ 0.13 = 200. A proportion of 0 is rejected, and the quotient has to be a whole number.
Confidence interval · counts
p-hat is found from the counts first. The Wilson score method then gives the interval center ± half-width [2]:
(1 + z² ÷ n)
z² ÷ 4n²) ÷ (1 + z² ÷ n)
z is the critical value of the standard normal distribution: 1.6449 for 90%, 1.9600 for 95% and 2.5758 for 99%. For 26 successes in 200 at 95%, the Wilson interval is 9.03% to 18.37%. The Wald normal approximation is the simpler and more widely taught form [2]:
The same sample gives a Wald interval of 8.34% to 17.66%. Wald limits that fall below 0% or above 100% are cut off at those bounds, and a caution appears when the sample has fewer than 10 successes or fewer than 10 failures.
Confidence interval · proportion
The Wilson and Wald formulas above are applied to the entered p-hat as it stands. A rounded proportion is not turned back into an exact success count, so 0.13 with n = 200 matches the counts result while 0.1 entered for 26 of 200 does not.
One-proportion z-test · counts
√(p₀ × (1 − p₀) ÷ n) [1]
p₀ is the null proportion, the value p-hat is tested against. The standard error in the divisor uses p₀, not p̂. The p-value is the standard normal tail area beyond z: both tails for p ≠ p₀, the lower tail for p < p₀ and the upper tail for p > p₀. For 26 successes in 200 against p₀ = 0.10, z = 0.03 ÷ 0.02121 = 1.414 [1], and the upper-tail p-value is 0.0786, so the null hypothesis is not rejected at 5%. The result also lists a two-sided Wald interval at the matching confidence level, which plays no part in the decision.
One-proportion z-test · proportion
The z statistic and p-value are calculated the same way from an entered p-hat. With p̂ = 0.13, n = 200 and p₀ = 0.10, the two-sided p-value is twice the one-tail area, 0.1573.
Required sample size
E is the margin as a decimal, so 5 percentage points is 0.05, and p is the expected proportion. Leaving p at 50% gives the largest sample, because p × (1 − p) peaks there [3]. At 95% confidence and a 5 point margin, n₀ = 1.96² × 0.25 ÷ 0.0025 = 384.15, which rounds up to 385 observations. When a finite population size N is entered, the sample is reduced [3]:
For a population of 2,000 the same settings need 323 observations. The result is always rounded up to a whole observation and never exceeds N.
What Is P-Hat in Statistics?
P-hat, written p̂ and read as "p with a hat", is the sample proportion: the share of a sample that has the characteristic being counted. It is the estimate of the population proportion p. The difference between the two is that p is a single fixed value for the whole population and is usually unknown, while p̂ comes from one sample and changes from sample to sample. If 26 of 200 tested items are defective, p̂ = 0.13, and the true defect rate p of the whole process is estimated to be near 13% [1].
Limits of This Estimate
- p-hat describes the sample. It says something about the population only when the sample was drawn at random and the observations are independent.
- The Wald interval can produce a lower limit below zero and is unreliable for small samples or proportions near 0 or 1. The Wilson interval cannot go negative and depends much less on n and p [2].
- The z-test rests on a normal approximation to the binomial distribution, which needs a large sample [1]. A caution appears when n × p₀ or n × (1 − p₀) is below 10, and an exact binomial test is the better choice there.
- Required sample size is a planning figure. It makes no allowance for nonresponse or for cluster and stratified designs, and the finite population formula applies only to simple random sampling without replacement.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, Section 7.2.4: sample proportion, the z statistic for one proportion and the 26 of 200 example
- NIST/SEMATECH e-Handbook of Statistical Methods, Section 7.2.4.1: Wilson interval limits and the Wald interval's weaknesses
- University of Florida IFAS Extension, Determining Sample Size (PEOD6), Equations 1 to 3: sample size for a proportion and the finite population correction

