Gamma distribution PDF calculator
The gamma distribution PDF calculator evaluates the probability density of a gamma-distributed continuous variable at a chosen nonnegative point.
Run — free
Enter a positive shape, a positive rate and the value of x, and the calculator returns the density together with its natural logarithm. This rate-based form is useful in reliability, waiting-time, insurance and Bayesian models. It also identifies the exact boundary behavior at zero, including the singular case for shapes below one, without silently substituting a scale parameter.
Enter shape, rate and the evaluation point
A gamma distribution is determined here by two positive parameters. The shape controls the overall form: values below one produce a curve that descends from a singularity at zero, a shape of one gives the exponential distribution, and larger shapes produce a density that rises and then falls. The rate controls how quickly values are concentrated toward zero. Enter rate directly, not scale; if a source gives scale, convert it with rate = 1 / scale before using the calculator. Finally, enter x as the nonnegative point where the density should be evaluated. The output is a density, not the probability of observing exactly x. For a continuous distribution, the probability at one exact point is zero; probabilities over intervals require integrating the density or using a cumulative distribution function. Every input must be finite. Shape and rate must be strictly greater than zero, while x may equal zero but cannot be negative. These checks prevent undefined parameterizations from producing plausible-looking numbers.
Understand the formula and numerical result
The calculator uses f(x) = rate^shape × x^(shape - 1) × exp(-rate × x) / Gamma(shape) for x at or above zero. Direct evaluation of those factors can overflow or underflow even when the final density is representable, so the implementation first works in logarithmic space. It computes shape × log(rate) + (shape - 1) × log(x) - rate × x - logGamma(shape), using a fixed Lanczos approximation for logGamma, and then exponentiates the result. The returned log density is useful when comparing very small likelihood contributions because it can remain finite after the ordinary density rounds down to zero. At x = 0 the implementation applies the exact limiting rules instead of taking log(0): the density is zero when shape is greater than one, equals rate when shape is one, and is unbounded when shape is below one. The unbounded value is represented by the string “Infinity” and flagged explicitly so the response remains valid JSON.
Use density values responsibly
A probability density can be greater than one, especially when a distribution is tightly concentrated, and that does not violate probability rules. What must remain one is the total area under the curve across the full support. Use this result to evaluate likelihoods, compare candidate parameter settings, inspect a fitted model or sample points for plotting. Do not interpret the density itself as a percentage or as the probability that the variable equals x. When multiplying densities across many observations, add the returned log densities instead; this reduces numerical underflow and matches common maximum-likelihood workflows. Parameterization deserves special attention because statistical libraries alternate between rate and scale. This calculator always uses rate, and the relationship is scale = 1 / rate. Check the convention in any paper, spreadsheet or software package before comparing answers. Results use JavaScript double-precision arithmetic and a deterministic approximation, which is appropriate for ordinary statistical calculation but does not replace arbitrary-precision software for extreme scientific parameter ranges or formal numerical certification.
What you can do with it
Evaluate a waiting-time model
Find the density at a particular duration when event waiting times are modeled with a gamma shape and rate.
Build a log-likelihood
Use the returned log density as one stable contribution to a parameter estimation or model comparison calculation.
Check statistical software
Verify a gamma PDF value while making the rate-versus-scale convention explicit.
FAQ
What does a gamma PDF value mean?
It is the height of the probability density curve at x. It is not the probability of observing exactly that value.
Does this calculator use rate or scale?
It uses rate. Convert a scale parameter by taking its reciprocal before calculating.
Why can the density be greater than one?
Density is height per unit of x, not probability by itself. The total area under the density is one.
What happens at x equal to zero?
The density is zero for shape above one, equals the rate for shape one, and is unbounded for shape below one.
Why is log density included?
Log density is more useful for combining very small likelihood values because addition in log space avoids many underflow problems.
What does the API calculation cost?
Each API request costs $0.002. The browser calculator can run the same deterministic logic directly on this page.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/stat/gamma-pdf \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"shape":3.5,"rate":2,"x":1.25}'const res = await fetch("https://api.kit.forhosting.com/stat/gamma-pdf", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"shape": 3.5,
"rate": 2,
"x": 1.25
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/gamma-pdf",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"shape": 3.5,
"rate": 2,
"x": 1.25
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/gamma-pdf", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"shape":3.5,"rate":2,"x":1.25}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"shape":3.5,"rate":2,"x":1.25}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/gamma-pdf", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"shape": 3.5,
"rate": 2,
"x": 1.25
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.gamma_pdf",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |