This calculator helps you compute the probabilities of a gamma distribution given the parameters α (shape) and θ (scale). You can find the probability of values being less than, greater than, or between specific values. The distribution chart shows the probability density function (PDF) of the gamma distribution, which models waiting times between Poisson events and is commonly used in reliability analysis, actuarial science, and climate modeling.
Definition: The gamma distribution is a continuous probability distribution that arises naturally in processes for which the waiting times between events are relevant.
Where:
library(tidyverse)
# Parameters
shape <- 2
scale <- 2
x1 <- 2
x2 <- 4
prob <- pgamma(x2, shape = shape, scale = scale) - pgamma(x1, shape = shape, scale = scale)
print(str_glue("P({x1} < X < {x2}) = {round(prob, 4)}")) # P(2 < X < 4) = 0.3298
# Calculate probability density at x1
density_at_x1 <- dgamma(x1, shape = shape, scale = scale)
print(str_glue("f({x1}) = {round(density_at_x1, 4)}")) # f(2) = 0.1839
# Calculate cumulative probability at x1
cdf_at_x1 <- pgamma(x1, shape = shape, scale = scale)
print(str_glue("P(X ≤ {x1}) = {round(cdf_at_x1, 4)}")) # P(X ≤ 2) = 0.2642
# mean and variance
mean <- shape * scale
variance <- shape * scale^2
print(str_glue("Mean: {round(mean, 4)}")) # Mean: 4
print(str_glue("Variance: {round(variance, 4)}")) # Variance: 8
# Create plot
x <- seq(0, 12, length.out = 1000)
y <- dgamma(x, shape = shape, scale = scale)
df <- tibble(x = x, y = y)
ggplot(df, aes(x = x, y = y)) +
geom_line(color = "blue") +
geom_area(data = subset(df, x >= x1 & x <= x2),
aes(x = x, y = y),
fill = "blue",
alpha = 0.2) +
labs(title = str_glue("Gamma Distribution (α = {shape}, θ = {scale})"),
x = "x",
y = "Probability Density",
caption = str_glue("P({x1} < X < {x2}) = {round(prob, 4)}")) +
theme_minimal()import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns
# Set parameters
shape = 2 # alpha
scale = 2 # theta
# Calculate probability between two values
x1, x2 = 2, 4
prob = stats.gamma.cdf(x2, a=shape, scale=scale) - stats.gamma.cdf(x1, a=shape, scale=scale)
print(f"P({x1} < X < {x2}) = {prob:.4f}")
# Create plot
x = np.linspace(0, 12, 1000)
pdf = stats.gamma.pdf(x, a=shape, scale=scale)
plt.figure(figsize=(10, 6))
plt.plot(x, pdf, 'blue', label='PDF')
# Add shaded area
x_shade = x[(x >= x1) & (x <= x2)]
pdf_shade = stats.gamma.pdf(x_shade, a=shape, scale=scale)
plt.fill_between(x_shade, pdf_shade, alpha=0.2, color='blue')
# Customize plot
plt.title(f'Gamma Distribution (α = {shape}, θ = {scale})')
plt.xlabel('x')
plt.ylabel('Probability Density')
plt.annotate(f'P({x1} < X < {x2}) = {prob:.4f}',
xy=(6, max(pdf)/2),
xytext=(6, max(pdf)/2))
plt.grid(True, alpha=0.3)
plt.show()This calculator helps you compute the probabilities of a gamma distribution given the parameters α (shape) and θ (scale). You can find the probability of values being less than, greater than, or between specific values. The distribution chart shows the probability density function (PDF) of the gamma distribution, which models waiting times between Poisson events and is commonly used in reliability analysis, actuarial science, and climate modeling.
Definition: The gamma distribution is a continuous probability distribution that arises naturally in processes for which the waiting times between events are relevant.
Where:
library(tidyverse)
# Parameters
shape <- 2
scale <- 2
x1 <- 2
x2 <- 4
prob <- pgamma(x2, shape = shape, scale = scale) - pgamma(x1, shape = shape, scale = scale)
print(str_glue("P({x1} < X < {x2}) = {round(prob, 4)}")) # P(2 < X < 4) = 0.3298
# Calculate probability density at x1
density_at_x1 <- dgamma(x1, shape = shape, scale = scale)
print(str_glue("f({x1}) = {round(density_at_x1, 4)}")) # f(2) = 0.1839
# Calculate cumulative probability at x1
cdf_at_x1 <- pgamma(x1, shape = shape, scale = scale)
print(str_glue("P(X ≤ {x1}) = {round(cdf_at_x1, 4)}")) # P(X ≤ 2) = 0.2642
# mean and variance
mean <- shape * scale
variance <- shape * scale^2
print(str_glue("Mean: {round(mean, 4)}")) # Mean: 4
print(str_glue("Variance: {round(variance, 4)}")) # Variance: 8
# Create plot
x <- seq(0, 12, length.out = 1000)
y <- dgamma(x, shape = shape, scale = scale)
df <- tibble(x = x, y = y)
ggplot(df, aes(x = x, y = y)) +
geom_line(color = "blue") +
geom_area(data = subset(df, x >= x1 & x <= x2),
aes(x = x, y = y),
fill = "blue",
alpha = 0.2) +
labs(title = str_glue("Gamma Distribution (α = {shape}, θ = {scale})"),
x = "x",
y = "Probability Density",
caption = str_glue("P({x1} < X < {x2}) = {round(prob, 4)}")) +
theme_minimal()import numpy as np
import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
import seaborn as sns
# Set parameters
shape = 2 # alpha
scale = 2 # theta
# Calculate probability between two values
x1, x2 = 2, 4
prob = stats.gamma.cdf(x2, a=shape, scale=scale) - stats.gamma.cdf(x1, a=shape, scale=scale)
print(f"P({x1} < X < {x2}) = {prob:.4f}")
# Create plot
x = np.linspace(0, 12, 1000)
pdf = stats.gamma.pdf(x, a=shape, scale=scale)
plt.figure(figsize=(10, 6))
plt.plot(x, pdf, 'blue', label='PDF')
# Add shaded area
x_shade = x[(x >= x1) & (x <= x2)]
pdf_shade = stats.gamma.pdf(x_shade, a=shape, scale=scale)
plt.fill_between(x_shade, pdf_shade, alpha=0.2, color='blue')
# Customize plot
plt.title(f'Gamma Distribution (α = {shape}, θ = {scale})')
plt.xlabel('x')
plt.ylabel('Probability Density')
plt.annotate(f'P({x1} < X < {x2}) = {prob:.4f}',
xy=(6, max(pdf)/2),
xytext=(6, max(pdf)/2))
plt.grid(True, alpha=0.3)
plt.show()