# P-Value Calculator

> Converts a test statistic into a p-value for the standard normal (z), Student t or chi-square distribution, with the chosen tails, the cumulative probability and the critical value at a given significance level.

- Calculator id: `p-value` · Category: Statistics & Probability (`statistics`) · Tool name: `calculate_p_value`
- Canonical page: https://tttkmbb.com/statistics/p-value · This document: https://tttkmbb.com/statistics/p-value.md · JSON definition: https://tttkmbb.com/statistics/p-value.json

## Purpose

Converts a test statistic into a p-value for the standard normal (z), Student t or chi-square distribution, with the chosen tails, the cumulative probability and the critical value at a given significance level.

**Use when:** You already have a z, t or chi-square statistic (and its degrees of freedom) from a test or a paper and need the p-value or the critical value.

**Do not use when:** You have the raw data and still need the statistic (use t-test, chi-square-test or proportion-z-test), or the statistic follows another distribution such as F.

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `statistic` | number |  | required | Observed value of the statistic (z, t or χ²). |
| `distribution` | enum: z \| t \| chi_square |  | optional, default "z" | Reference distribution of the statistic under the null hypothesis. |
| `degrees_of_freedom` | number |  | optional | Required for t and chi_square; ignored for z. May be fractional (Welch t-test). (> 0, max 10000000) |
| `tails` | enum: two \| right \| left |  | optional, default "two" | Which tail(s) count as at least as extreme. For chi_square the p-value is always the upper tail. |
| `alpha` | number |  | optional, default 0.05 | Significance level as a probability (0.05 = 5 %), not a percentage. Confidence intervals and critical values use level 1 − alpha. (> 0) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `p_value` | number |  | Probability, under H0, of a statistic at least as extreme as the observed one in the chosen tail(s). |
| `cumulative_probability` | number |  | P(X ≤ statistic) under the reference distribution. |
| `critical_value` | number |  | Statistic value at which p would equal alpha (two-tailed: the positive bound ±value; left-tailed: negative). |
| `distribution_used` | string |  | Reference distribution and degrees of freedom. |
| `significant` | boolean |  | true when p_value < alpha. |
| `decision` | string |  | Plain-language conclusion. |

## Formula

`two-tailed (z, t): p = 2 × (1 − F(|statistic|)); right: p = 1 − F(statistic); left: p = F(statistic); chi_square: p = 1 − F(statistic) where F is the CDF of the reference distribution`

The normal CDF uses the Abramowitz & Stegun erf approximation (error < 1.5·10⁻⁷); the t CDF uses the regularized incomplete beta function and the chi-square CDF the regularized incomplete gamma function (Numerical Recipes continued fractions). Critical values are found by bisection.

## Data Sources

- Wikipedia – p-value — https://en.wikipedia.org/wiki/P-value (reference, retrieved 2026-09-24)
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.6.6.4 t Distribution — https://www.itl.nist.gov/div898/handbook/eda/section3/eda3664.htm (government, retrieved 2026-09-24)
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.6.6.6 Chi-Square Distribution — https://www.itl.nist.gov/div898/handbook/eda/section3/eda3666.htm (government, retrieved 2026-09-24)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/p-value?statistic=…`
- `POST https://tttkmbb.com/api/v1/calculate/p-value` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/p-value · OpenAPI operationId `calculate_p_value` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "p-value", "inputs": {…}}`

## Example

- t = 2.0 with 10 df, two-tailed: inputs `{"statistic":2,"distribution":"t","degrees_of_freedom":10,"tails":"two"}` → `{"p_value":0.073388,"cumulative_probability":0.963306,"critical_value":2.2281,"significant":false}`
- Chi-square = 3.84 with 1 df: inputs `{"statistic":3.84,"distribution":"chi_square","degrees_of_freedom":1}` → `{"p_value":0.050044,"cumulative_probability":0.949956,"critical_value":3.8415,"significant":false}`

```
GET https://tttkmbb.com/api/v1/calculate/p-value?statistic=2&distribution=t&degrees_of_freedom=10&tails=two
```

## Limitations

You have the raw data and still need the statistic (use t-test, chi-square-test or proportion-z-test), or the statistic follows another distribution such as F. The normal CDF uses the Abramowitz & Stegun erf approximation (error < 1.5·10⁻⁷); the t CDF uses the regularized incomplete beta function and the chi-square CDF the regularized incomplete gamma function (Numerical Recipes continued fractions). Critical values are found by bisection. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**One-tailed or two-tailed?**

Two-tailed unless the direction of the effect was specified before looking at the data. A two-tailed p is twice the one-tailed p in the observed direction.

**Why is the chi-square p-value always upper-tailed?**

The chi-square statistic measures total discrepancy, so only large values contradict H0; goodness-of-fit and independence tests use the upper tail.

**What does p < 0.05 mean?**

If H0 were true, a statistic at least this extreme would occur in fewer than 5 % of repetitions. It is not the probability that H0 is true.

## Related

- [T-Test Calculator](https://tttkmbb.com/statistics/t-test.md) — Compute t and its p-value from data.
- [Chi-Square Test Calculator](https://tttkmbb.com/statistics/chi-square-test.md) — Chi-square statistic from observed counts.
- [Z-Score Calculator](https://tttkmbb.com/statistics/z-score.md) — Standardise a value to obtain a z statistic.
