Probability Density Function Calculator

Check that a density integrates to 1, then extract probabilities, mean, and variance from it.

Probability Density Function Calculator

Verify a density, then find P(a ≤ X ≤ b), the mean, and the variance by integration.

What Is a Probability Density Function?

A probability density function (PDF) describes a continuous random variable by giving probability as area rather than height. For a density f(x) on a support interval, three integrals answer every basic question:

∫ f dx = 1 (total probability),   P(a ≤ X ≤ b) = ∫ab f dx,   μ = ∫ x f dx,   σ² = ∫ x² f dx − μ²

The defining feature is that probability lives in areas: the chance X falls in an interval is the area under the density over that interval, and the probability of any single exact value is zero. This calculator verifies that a candidate density is non-negative and integrates to 1, then computes interval probabilities, the mean, the variance, and the standard deviation, all as definite integrals, shading the probability window and marking the mean on the graph.

How to Use the PDF Calculator

Enter a candidate density f(x), its support interval [a, b], and a probability window. The steps check non-negativity, verify (or report) the normalization ∫f = 1, and if the function does not integrate to 1 they normalize it and continue. Then they compute P over your window, the mean, the variance, and the standard deviation. The graph shades the probability window under the density and marks the mean. This is the probability-theory face of the definite integral; the mean and variance are the first two weighted averages of the distribution.

Worked Example

Consider f(x) = 3x² on [0, 1]. First verify it is a density: it is non-negative there, and ∫01 3x² dx = [x³]01 = 1, so it qualifies. The probability X exceeds 0.5 is

P(0.5 ≤ X ≤ 1) = ∫0.51 3x² dx = 1 − 0.125 = 0.875

The density rises steeply, so most probability piles up near 1, exactly what 0.875 reflects. The mean is μ = ∫01 x·3x² dx = ∫ 3x³ dx = 3/4 = 0.75, pulled toward the heavy right side. The variance is ∫ x²·3x² dx − μ² = 3/5 − 9/16 = 0.0375, giving a standard deviation of about 0.194. This distribution, the Beta(3,1) law, models a proportion strongly skewed toward 1, and every summary comes from one of the four integrals.

Why Probability Is Area

For a continuous variable, no single value can carry positive probability, there are uncountably many possible outcomes, so any one must have probability zero, yet they cannot all be zero if the total is one. The resolution is to assign probability to intervals via a density: f(x)dx is the infinitesimal probability of landing in a sliver of width dx near x, and integrating accumulates these slivers into interval probabilities. The density itself is not a probability (it can exceed 1, as a sharply peaked distribution does); only its integral over a region is. This is why the two universal requirements are non-negativity (probabilities cannot be negative) and normalization (∫f = 1, some outcome is certain). The mean ∫ x f dx is the density-weighted average position, the balance point of the distribution; the variance ∫(x − μ)² f dx is the weighted average squared spread, and its root, the standard deviation, is the distribution's characteristic width in the units of X. The cumulative distribution function F(x) = ∫−∞x f is the running-total probability, and the Fundamental Theorem of Calculus makes the density its derivative, F′ = f, the same accumulation-and-rate duality that runs through all of integration.

Common Mistakes to Avoid

  • Treating the density value as a probability. f(x) is a rate, not a probability; it can exceed 1. Only ∫ f over an interval is a probability, always between 0 and 1.
  • Skipping the normalization check. A function is a valid density only if it is non-negative and integrates to 1. Forgetting to verify (or normalize) means every subsequent probability and moment is scaled wrong.
  • Using the wrong moment for variance. Variance is E[X²] − μ², not E[X²] alone. Dropping the −μ² overstates the spread, sometimes drastically.
  • Confusing P(X = c) with f(c). For continuous variables P(X = c) = 0 for every c, because a single point has zero width. Only ranges carry probability.
  • Ignoring the support. The density is zero outside its support interval; integrating a formula beyond where it is defined (or where it should be zero) corrupts the total and the moments.

Real-World Applications

Probability density functions are the language of every continuous uncertainty. Statistics builds hypothesis tests, confidence intervals, and regression on densities like the normal, t, chi-squared, and F distributions, each summarized by exactly these integrals. Reliability engineering models component lifetimes with exponential and Weibull densities, computing failure probabilities and mean time to failure as ∫ x f dx. Finance models asset returns with densities to price options and compute value-at-risk, a tail probability ∫ f. Physics uses densities for particle positions in quantum mechanics (|ψ|² is a probability density), for velocity distributions in kinetic theory (the Maxwell-Boltzmann density), and for measurement error. Machine learning fits densities to data (density estimation, generative models) and evaluates likelihoods that are products of density values. Signal processing characterizes noise by its density. In every case the same four operations recur, check it integrates to 1, integrate to get a probability, take the first moment for the mean, the second for the variance, and this tool performs all four, making it a hands-on gateway from calculus to the entire edifice of continuous probability and statistics. The random sampling of the Monte Carlo calculator is the computational partner to these analytic integrals.

Frequently Asked Questions

What makes a function a valid probability density?

Two conditions: it must be non-negative everywhere (probabilities cannot be negative) and integrate to exactly 1 over its support (some outcome is certain). Any non-negative function with a finite positive integral can be normalized into a density by dividing by that integral.

Why is the probability of an exact value zero?

Because a single point has zero width, and probability for continuous variables is area (width times density). With uncountably many possible values, each must carry zero probability, yet intervals carry positive probability through integration. This is the defining feature of continuous distributions.

Can a density value be greater than 1?

Yes. The density is a rate of probability per unit length, not a probability. A sharply concentrated distribution (small support or a tall spike) can have density values far above 1; only the integral over a region, which stays in [0, 1], is a probability.

How do I compute the mean from a density?

The mean is the density-weighted average of x: μ = ∫ x f(x) dx over the support. It is the balance point where a plate cut to the density's shape would sit level, pulled toward wherever the density places the most area.

Why does variance subtract the mean squared?

Variance is the average squared deviation from the mean, ∫(x − μ)² f dx, which algebraically equals E[X²] − μ². The subtraction removes the part of the second moment that comes merely from the mean's location, leaving pure spread about the center.

What is the cumulative distribution function?

The CDF F(x) = ∫−∞x f(t) dt is the probability that X is at most x, the running total of the density. By the Fundamental Theorem of Calculus, F′ = f, so the density is the CDF's derivative and the CDF is the density's accumulation.

What if my function does not integrate to 1?

If it is non-negative with a finite positive integral c, divide by c to normalize: f/c is a proper density. The tool does this automatically and computes all statistics from the normalized version, reporting the constant it used.

How is the standard deviation interpreted?

It is the square root of the variance, expressed in the same units as X, and it measures the distribution's typical spread about the mean. For many distributions, most probability lies within a couple of standard deviations of the mean, giving a quick sense of the likely range.

How does this relate to the normal distribution?

The normal (Gaussian) density is the most important continuous distribution, and its probabilities are computed by exactly this integration, though its integral has no elementary form and is expressed through the error function. The mean and variance are its two parameters, computed by the same moment integrals used here.

Can these integrals be done for any density?

Conceptually yes, though many densities (the normal, for one) lack elementary antiderivatives and require numerical integration, which is what this tool uses. The four operations, normalize, integrate for probability, first moment, second moment, apply universally regardless of whether closed forms exist.