A P-value (probability value) is a fundamental metric used in statistical hypothesis testing. It quantifies the evidence against the null hypothesis (H₀). Specifically, it represents the probability of obtaining test results at least as extreme as the results actually observed, assuming that the null hypothesis is correct.
Z-Score vs. T-Score
This calculator supports two primary distributions used in research:
Z-Distribution (Normal): Used when the population standard deviation is known or the sample size is large (typically n > 30).
T-Distribution: Used when the population standard deviation is unknown and the sample size is small. This distribution requires Degrees of Freedom (usually n – 1).
Interpretation Guide
In most scientific fields, a P-value of 0.05 is used as the threshold for statistical significance:
p ≤ 0.05: Strong evidence against the null hypothesis. You reject the null hypothesis and conclude the result is "statistically significant."
p > 0.05: Weak evidence against the null hypothesis. You fail to reject the null hypothesis; the results could likely be due to random chance.
Calculation Example
Suppose you are testing a new plant fertilizer. Your calculated Z-score is 1.96. If you are performing a two-tailed test:
Find the area in the tails beyond +1.96 and -1.96.
In a standard normal distribution, this area is approximately 0.025 for each tail.
Summed together, the P-value is 0.05.
function toggleDf() {
var dist = document.getElementById("distributionType").value;
var container = document.getElementById("df-container");
if (dist === "t") {
container.style.display = "flex";
} else {
container.style.display = "none";
}
}
function erf(x) {
var a1 = 0.254829592;
var a2 = -0.284496736;
var a3 = 1.421413741;
var a4 = -1.453152027;
var a5 = 1.061405429;
var p = 0.3275911;
var sign = 1;
if (x 0) return 1 – 0.5 * p;
return 0.5 * p;
}
function ibeta(a, b, x) {
if (x === 0) return 0;
if (x === 1) return 1;
var lbeta = logGamma(a) + logGamma(b) – logGamma(a + b);
var front = Math.exp(a * Math.log(x) + b * Math.log(1 – x) – lbeta) / a;
var f = 1, c = 1, d = 0, h;
for (var i = 0; i <= 100; i++) {
var m = i / 2;
var num;
if (i === 0) {
num = 1;
} else if (i % 2 === 0) {
num = (m * (b – m) * x) / ((a + 2 * m – 1) * (a + 2 * m));
} else {
var m1 = (i – 1) / 2;
num = -((a + m1) * (a + b + m1) * x) / ((a + 2 * m1) * (a + 2 * m1 + 1));
}
d = 1 + num * d;
if (Math.abs(d) < 1e-10) d = 1e-10;
d = 1 / d;
c = 1 + num / c;
if (Math.abs(c) < 1e-10) c = 1e-10;
h = c * d;
f *= h;
if (Math.abs(h – 1) < 1e-10) break;
}
return front * (f – 1);
}
function logGamma(z) {
var coeff = [76.18009172947146, -86.50532032941677, 24.01409824083091, -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5];
var x = z, y = z, tmp = x + 5.5;
tmp -= (x + 0.5) * Math.log(tmp);
var ser = 1.000000000190015;
for (var j = 0; j <= 5; j++) ser += coeff[j] / ++y;
return -tmp + Math.log(2.5066282746310005 * ser / x);
}
function calculatePValue() {
var score = parseFloat(document.getElementById("testStatistic").value);
var dist = document.getElementById("distributionType").value;
var tail = document.getElementById("tailType").value;
var alpha = parseFloat(document.getElementById("significanceLevel").value);
var df = parseInt(document.getElementById("degreesFreedom").value);
var resultDisplay = document.getElementById("p-val-display");
var interpretDisplay = document.getElementById("p-val-interpretation");
var resultBox = document.getElementById("p-val-result-box");
if (isNaN(score)) {
alert("Please enter a valid Test Statistic.");
return;
}
var pValue;
if (dist === "z") {
var cdf = normalCDF(score);
if (tail === "left") {
pValue = cdf;
} else if (tail === "right") {
pValue = 1 – cdf;
} else {
pValue = 2 * (1 – normalCDF(Math.abs(score)));
}
} else {
if (isNaN(df) || df <= 0) {
alert("Please enter a valid Degrees of Freedom (greater than 0).");
return;
}
var cdfT = tCDF(score, df);
if (tail === "left") {
pValue = cdfT;
} else if (tail === "right") {
pValue = 1 – cdfT;
} else {
pValue = 2 * (1 – tCDF(Math.abs(score), df));
}
}
// Clean p-value bounds
if (pValue 1) pValue = 1;
resultDisplay.innerText = pValue.toFixed(6);
resultBox.style.display = "block";
if (pValue " + alpha + "). Fail to reject the null hypothesis.";
interpretDisplay.style.color = "#e67e22";
}
}