# P-hat Calculator (Sample Proportion)

URL: https://speedycalculator.com/calculators/statistics/p-hat/
Last updated: 2026-10-30

> The p-hat calculator finds the sample proportion p̂ = x/n from the number of successes and the sample size, along with q̂ = 1 − p̂, the standard error, the margin of error and Wald and Wilson confidence intervals for the population proportion.

## Inputs

- Sample size (n)
- Number of successes / occurrences (x)
- Confidence level

## Results

- Sample proportion p̂
- p̂ as a percentage
- q̂ = 1 − p̂
- Standard error of p̂
- Critical value z
- Margin of error
- Wald interval – lower
- Wald interval – upper
- Wilson interval – lower
- Wilson interval – upper
- Normal approximation OK (≥ 10 successes and failures)?

## Formula

```
p̂ = x ÷ n · q̂ = 1 − p̂
SE = √(p̂ q̂ ÷ n) · Wald CI: p̂ ± z × SE
Wilson CI: [p̂ + z²/2n ± z√(p̂q̂/n + z²/4n²)] ÷ (1 + z²/n)
```

## Explanation

P-hat (p̂) is the sample proportion: the share of a sample that has a given characteristic. If 85 of 250 surveyed customers say they would recommend a product, p̂ = 85 ÷ 250 = 0.34. It is the natural estimate of the unknown population proportion p – and also its maximum-likelihood estimate.

Because a different sample would give a slightly different p̂, the calculator also shows how precise the estimate is. The standard error √(p̂(1 − p̂)/n) shrinks with the square root of the sample size, so quadrupling n halves it. Pick a confidence level to get the margin of error and two confidence intervals: the classic Wald interval taught in introductory courses and the Wilson score interval, which behaves much better for small samples or proportions near 0 or 1.

Finally it checks the usual rule of thumb for the normal approximation – at least 10 successes and 10 failures. When that fails, rely on the Wilson interval or an exact method rather than the Wald interval.

### How to use the P-hat Calculator

- **Sample size (n)**
- **Number of successes / occurrences (x)**
- **Confidence level**

Results update as you type, and everything is calculated in your browser.

### How it works

Divide the successes by the sample size to get p̂. The standard error uses p̂ itself; the z value comes from the chosen confidence level. The Wilson interval is centred slightly towards 0.5 and never leaves the range 0 to 1.

### Worked example

85 of 250 customers would recommend the product. p̂ = 85 ÷ 250 = 0.34 and q̂ = 0.66. SE = √(0.34 × 0.66 ÷ 250) = 0.02996. At 95% confidence z = 1.96, so the margin of error is 0.0587 and the Wald interval is 0.2813 to 0.3987. The Wilson interval is 0.2841 to 0.4007. There are 85 successes and 165 failures, so the normal approximation is fine.

### Sample size and precision

n (with p̂ = 0.34)Standard error95% margin of error1000.0474±0.09282500.0300±0.05871,0000.0150±0.02944,0000.0075±0.0147

### Inputs explained

FieldWhat to enterSample size (n)A numberNumber of successes / occurrences (x)A numberConfidence levelChoose one: 80%, 90%, 95%, 98% …

### What each result means

- **Sample proportion p̂** = [Number of successes ÷ occurrences (x)]÷[Sample size (n)]
- **p̂ as a percentage** = [Number of successes ÷ occurrences (x)]÷[Sample size (n)]×100
- **q̂ = 1 − p̂** = 1 - [Sample proportion p̂]
- **Standard error of p̂** = sqrt([Sample proportion p̂]×[q̂ = 1 − p̂]÷[Sample size (n)])
- **Critical value z** = ninv(1 - (1 - [Confidence level])÷2)
- **Margin of error** = [Critical value z]×[Standard error of p̂]
- **Wald interval – lower** = max(0, [Sample proportion p̂] - [Margin of error])
- **Wald interval – upper** = min(1, [Sample proportion p̂] + [Margin of error])
- **Wilson interval – lower** = (([Sample proportion p̂] + [Critical value z]^2÷(2×[Sample size (n)])) - [Critical value z]×sqrt([Sample proportion p̂]×[q̂ = 1 − p̂]÷[Sample size (n)] + [Critical value z]^2÷(4×[Sample size (n)]^2)))÷(1 + [Critical value z]^2÷[Sample size (n)])
- **Wilson interval – upper** = (([Sample proportion p̂] + [Critical value z]^2÷(2×[Sample size (n)])) + [Critical value z]×sqrt([Sample proportion p̂]×[q̂ = 1 − p̂]÷[Sample size (n)] + [Critical value z]^2÷(4×[Sample size (n)]^2)))÷(1 + [Critical value z]^2÷[Sample size (n)])

## Worked example

Inputs — Sample size (n): 250; Number of successes / occurrences (x): 85; Confidence level: 95%.

Results — **Sample proportion p̂ = 0.34**; p̂ as a percentage = 34 %; q̂ = 1 − p̂ = 0.66; Standard error of p̂ = 0.02996; Critical value z = 1.96; Margin of error = 0.05872; Wald interval – lower = 0.2813; Wald interval – upper = 0.3987; Wilson interval – lower = 0.2841; Wilson interval – upper = 0.4007; Normal approximation OK (≥ 10 successes and failures)? = Yes.

## Key terms

- **Sample proportion (p̂)**: Successes divided by sample size.
- **Population proportion (p)**: The true share in the whole population.
- **Standard error**: The standard deviation of p̂ across repeated samples.
- **Wilson score interval**: A confidence interval for a proportion with better small-sample behaviour than the Wald interval.

## FAQ

**What is p-hat?**
The sample proportion p̂ = x/n, the fraction of the sample with the characteristic of interest.

**How do I calculate p-hat?**
Divide the number of successes by the sample size. 450 "yes" answers out of 700 give p̂ = 0.6429; 25 successes in 60 trials give 0.4167.

**What is q-hat?**
1 − p̂, the sample proportion of failures.

**What is the standard error of p-hat?**
√(p̂(1 − p̂)/n). For p̂ = 0.34 and n = 250 it is 0.0300.

**How is p-hat different from p?**
p is the true population proportion, usually unknown; p̂ is its estimate from one sample.

**When is the normal approximation valid?**
When n·p̂ and n·(1 − p̂) are both at least about 10 (some texts use 5).

**Wald or Wilson interval?**
Wilson. It has close to the stated coverage even for small n or extreme proportions; Wald can be badly off and can extend below 0 or above 1.


## Sources

- [Penn State STAT 500 – Applied Statistics](https://online.stat.psu.edu/stat500/)
- [OpenStax – Introductory Statistics 2e](https://openstax.org/details/books/introductory-statistics-2e)
- [NIST/SEMATECH e-Handbook of Statistical Methods](https://www.itl.nist.gov/div898/handbook/)
