Discrete Distributions
Bernoulli Distribution
x <- 0:1
df_data <- data.frame(x = rep(x, 7),
prob_param = factor(rep(c(0.1, 0.2, 0.3, 0.5, 0.7, 0.8, 0.9), each = length(x))),
density = c(
dbinom(x, size = 1, prob = 0.1),
dbinom(x, size = 1, prob = 0.2),
dbinom(x, size = 1, prob = 0.3),
dbinom(x, size = 1, prob = 0.5),
dbinom(x, size = 1, prob = 0.7),
dbinom(x, size = 1, prob = 0.8),
dbinom(x, size = 1, prob = 0.9)
))
ggplot(df_data, aes(x = factor(x), y = density, fill = prob_param)) +
geom_bar(stat = "identity", position = "dodge", width = 0.7) +
scale_fill_brewer(palette = "Dark2", name = "Probability (p)") +
labs(title = "Bernoulli Distributions with Different Probabilities",
x = "Outcome (0 = Failure, 1 = Success)", y = "Probability") +
guides(fill = guide_legend(nrow = 1)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("bernoulli_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Binomial Distribution
x <- 0:30
df_data <- data.frame(x = rep(x, 7),
params = factor(rep(c("n=20, p=0.1", "n=20, p=0.3", "n=20, p=0.5",
"n=20, p=0.7", "n=20, p=0.9", "n=10, p=0.5", "n=30, p=0.5"),
each = length(x))),
density = c(
dbinom(x, size = 20, prob = 0.1),
dbinom(x, size = 20, prob = 0.3),
dbinom(x, size = 20, prob = 0.5),
dbinom(x, size = 20, prob = 0.7),
dbinom(x, size = 20, prob = 0.9),
dbinom(x, size = 10, prob = 0.5),
dbinom(x, size = 30, prob = 0.5)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_segment(aes(xend = x, yend = 0), linewidth = 0.8, alpha = 0.7) +
geom_point(size = 2) +
scale_color_brewer(palette = "Dark2", name = "Parameters") +
labs(title = "Binomial Distributions with Different Parameters",
x = "Number of Successes", y = "Probability") +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("binomial_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Poisson Distribution
x <- 0:20
df_data <- data.frame(x = rep(x, 7),
lambda = factor(rep(c(0.5, 1, 2, 3, 5, 8, 10), each = length(x))),
density = c(
dpois(x, lambda = 0.5),
dpois(x, lambda = 1),
dpois(x, lambda = 2),
dpois(x, lambda = 3),
dpois(x, lambda = 5),
dpois(x, lambda = 8),
dpois(x, lambda = 10)
))
ggplot(df_data, aes(x = x, y = density, color = lambda)) +
geom_segment(aes(xend = x, yend = 0), linewidth = 0.8, alpha = 0.7) +
geom_point(size = 2) +
scale_color_brewer(palette = "Dark2", name = "λ (Lambda)") +
labs(title = "Poisson Distributions with Different Lambda Values",
x = "Number of Events", y = "Probability") +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("poisson_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Geometric Distribution
x <- 0:20
df_data <- data.frame(x = rep(x, 7),
prob_param = factor(rep(c(0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.9), each = length(x))),
density = c(
dgeom(x, prob = 0.1),
dgeom(x, prob = 0.2),
dgeom(x, prob = 0.3),
dgeom(x, prob = 0.4),
dgeom(x, prob = 0.5),
dgeom(x, prob = 0.7),
dgeom(x, prob = 0.9)
))
ggplot(df_data, aes(x = x, y = density, color = prob_param)) +
geom_point(size = 2) +
geom_line(linewidth = 0.8) +
scale_color_brewer(palette = "Dark2",
name = "Probability (p)",
labels = c("0.1", "0.2", "0.3", "0.4", "0.5", "0.7", "0.9")) +
labs(title = "Geometric Distributions with Different Probability Values",
x = "Number of Failures Before First Success",
y = "Probability") +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("geometric_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
HyperGeometric Distribution
x <- 0:60
df_data <- data.frame(x = rep(x, 3),
params = factor(rep(c("N=500, K=50, n=100", "N=500, K=60, n=200",
"N=500, K=70, n=300"),
each = length(x))),
density = c(
dhyper(x, m=50, n=450, k=100),
dhyper(x, m=60, n=440, k=200),
dhyper(x, m=70, n=430, k=300)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_point(size = 1) +
geom_line(linewidth = 0.8) +
scale_color_brewer(palette = "Dark2",
name = "Parameters: ") +
labs(title = "Hypergeometric Distributions with Different Parameters",
x = "Number of Successes",
y = "Probability") +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 10)
)

ggsave("hypergeometric_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Categorical Distribution
categories <- 1:5
df_data <- data.frame(
category = rep(categories, 3),
distribution = factor(rep(c("Uniform", "Skewed Right", "Peaked"), each = length(categories))),
probability = c(
c(0.2, 0.2, 0.2, 0.2, 0.2),
c(0.5, 0.25, 0.15, 0.07, 0.03),
c(0.1, 0.2, 0.4, 0.2, 0.1)
))
ggplot(df_data, aes(x = category, y = probability, fill = distribution)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_brewer(palette = "Dark2", name = "Distribution Type") +
scale_x_continuous(breaks = categories) +
labs(title = "Categorical Distributions with Different Probability Patterns",
x = "Category", y = "Probability") +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("categorical_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Continuous Distributions
Uniform Distribution
x <- seq(-2, 2, length.out = 1000)
df <- data.frame(x = rep(x, 1),
params = factor(rep(c("U(-1,1)"), each = length(x))),
density = c(
dunif(x, min = -1, max = 1)
))
ggplot(df, aes(x = x, y = density, color = params, fill = params)) +
geom_line(linewidth = 1) +
geom_area(alpha = 0.3) +
scale_color_brewer(palette = "Dark2",
name = "Distribution") +
scale_fill_brewer(palette = "Dark2",
name = "Distribution") +
labs(title = "Uniform Distribution",
x = "x",
y = "Density") +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("uniform_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
x <- seq(-2, 4, length.out = 1000)
df <- data.frame(x = rep(x, 3),
params = factor(rep(c("U(-1,1)", "U(0.5,1)", "U(1,3)"), each = length(x))),
density = c(
dunif(x, min = -1, max = 0),
dunif(x, min = 0.5, max = 1),
dunif(x, min = 1, max = 3)
))
ggplot(df, aes(x = x, y = density, color = params, fill = params)) +
geom_line(linewidth = 1) +
geom_area(alpha = 0.3) +
scale_color_brewer(palette = "Dark2",
name = "Distribution") +
scale_fill_brewer(palette = "Dark2",
name = "Distribution") +
labs(title = "Uniform Distributions with Different Ranges",
x = "x",
y = "Density") +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("uniform_distribution2.png", width = 10, height = 6, units = "in", dpi = 300)
Normal Distribution
x <- seq(-4, 4, length.out = 1000)
df <- data.frame(x = rep(x, 7),
variance = factor(rep(c(0.25, 0.5, 1, 2, 4, 8, 16), each = length(x))),
density = c(
dnorm(x, mean = 0, sd = sqrt(0.25)),
dnorm(x, mean = 0, sd = sqrt(0.5)),
dnorm(x, mean = 0, sd = 1),
dnorm(x, mean = 0, sd = sqrt(2)),
dnorm(x, mean = 0, sd = sqrt(4)),
dnorm(x, mean = 0, sd = sqrt(8)),
dnorm(x, mean = 0, sd = sqrt(16))
))
ggplot(df, aes(x = x, y = density, color = variance)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Variance",
labels = c("0.25", "0.5", "1.0", "2.0", "4.0", "8.0", "16.0")) +
labs(title = "Normal Distributions with Different Variances",
x = "x",
y = "Density") +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("normal_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Student T-Distribution
x <- seq(-4, 4, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
df_param = factor(rep(c(1, 2, 3, 5, 10, 20, 30), each = length(x))),
density = c(
dt(x, df = 1),
dt(x, df = 2),
dt(x, df = 3),
dt(x, df = 5),
dt(x, df = 10),
dt(x, df = 20),
dt(x, df = 30)
))
ggplot(df_data, aes(x = x, y = density, color = df_param)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Degrees of Freedom") +
labs(title = "Student's T-Distributions with Different Degrees of Freedom",
x = "x",
y = "Density") +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("studentt_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Chi-squared Distribution
x <- seq(0, 8, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
df_param = factor(rep(c(1, 2, 3, 4, 5, 6, 7), each = length(x))),
density = c(
dchisq(x, df = 1),
dchisq(x, df = 2),
dchisq(x, df = 3),
dchisq(x, df = 4),
dchisq(x, df = 5),
dchisq(x, df = 6),
dchisq(x, df = 7)
))
ggplot(df_data, aes(x = x, y = density, color = df_param)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Degrees of Freedom") +
labs(title = "Chi-Squared Distributions with Different Degrees of Freedom",
x = "x",
y = "Density") +
ylim(c(0,1)) +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("chisq_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Exponential Distribution
x <- seq(0, 4, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
df_param = factor(rep(c(0.25, 0.5, 0.75, 1, 1.5, 5, 10), each = length(x))),
density = c(
dexp(x, rate = 0.25),
dexp(x, rate = 0.5),
dexp(x, rate = 0.75),
dexp(x, rate = 1),
dexp(x, rate = 1.5),
dexp(x, rate = 5),
dexp(x, rate = 10)
))
ggplot(df_data, aes(x = x, y = density, color = df_param)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Lambda") +
labs(title = "Exponential Distributions with Different Lambda Values",
x = "x",
y = "Density") +
ylim(c(0,2)) +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)
## Warning: Removed 87 rows containing missing values or values outside the scale range
## (`geom_line()`).

ggsave("exponential_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
## Warning: Removed 87 rows containing missing values or values outside the scale range
## (`geom_line()`).
Gamma Distribution
x <- seq(0, 4, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
params = factor(rep(c("α=0.5, λ=1", "α=0.75, λ=1", "α=1, λ=1", "α=2, λ=1",
"α=0.75, λ=2", "α=1, λ=2", "α=2, λ=2"),
each = length(x)),
levels = c("α=0.5, λ=1", "α=0.75, λ=1", "α=1, λ=1", "α=2, λ=1",
"α=0.75, λ=2", "α=1, λ=2", "α=2, λ=2")),
density = c(
dgamma(x, shape=0.5, rate = 1),
dgamma(x, shape=0.75, rate = 1),
dgamma(x, shape=1.0, rate = 1),
dgamma(x, shape=2.0, rate = 1),
dgamma(x, shape=0.75, rate = 2),
dgamma(x, shape=1, rate = 2),
dgamma(x, shape=2, rate = 2)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Lambda") +
labs(title = "Gamma Distributions with Different Alpha (Shape) and Lambda (Rate) Values",
x = "x",
y = "Density") +
ylim(c(0,2)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("gamma_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Beta Distribution
x <- seq(0, 1, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
params = factor(rep(c("α=0.5, β=0.5", "α=0.1, β=1", "α=2, β=1", "α=1, β=3",
"α=2, β=2", "α=5, β=2", "α=2, β=5"),
each = length(x)),
levels = c("α=0.5, β=0.5", "α=1, β=1", "α=2, β=1", "α=1, β=3",
"α=2, β=2", "α=5, β=2", "α=2, β=5")),
density = c(
dbeta(x, shape1 = 0.5, shape2 = 0.5),
dbeta(x, shape1 = 1, shape2 = 1),
dbeta(x, shape1 = 2, shape2 = 1),
dbeta(x, shape1 = 1, shape2 = 3),
dbeta(x, shape1 = 2, shape2 = 2),
dbeta(x, shape1 = 5, shape2 = 2),
dbeta(x, shape1 = 2, shape2 = 5)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Lambda") +
labs(title = "Beta Distributions with Different Alpha and Beta Values",
x = "x",
y = "Density") +
ylim(c(0,3)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)
## Warning: Removed 1000 rows containing missing values or values outside the scale range
## (`geom_line()`).

ggsave("beta_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
## Warning: Removed 1000 rows containing missing values or values outside the scale range
## (`geom_line()`).
Inverse Gaussian / Wald Distribution
x <- seq(0.01, 5, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
params = factor(rep(c("μ=1, λ=0.5", "μ=1, λ=1", "μ=1, λ=3",
"μ=1, λ=5", "μ=2, λ=1", "μ=3, λ=1", "μ=0.5, λ=1"),
each = length(x))),
density = c(
dinvgauss(x, mean = 1, shape = 0.5),
dinvgauss(x, mean = 1, shape = 1),
dinvgauss(x, mean = 1, shape = 3),
dinvgauss(x, mean = 1, shape = 5),
dinvgauss(x, mean = 2, shape = 1),
dinvgauss(x, mean = 3, shape = 1),
dinvgauss(x, mean = 0.5, shape = 1)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Parameters") +
labs(title = "Inverse Gaussian (Wald) Distributions with Different Parameters",
x = "x",
y = "Density") +
ylim(c(0, 2)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("wald_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Logistic Distribution
x <- seq(-5, 15, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
params = factor(rep(c("μ=0, s=1", "μ=5, s=2", "μ=9, s=3",
"μ=9, s=4", "μ=6, s=2", "μ=2, s=1", "μ=3, s=3"),
each = length(x))),
density = c(
dlogis(x, location = 0, scale = 1),
dlogis(x, location = 5, scale = 2),
dlogis(x, location = 9, scale = 3),
dlogis(x, location = 9, scale = 4),
dlogis(x, location = 6, scale = 2),
dlogis(x, location = 2, scale = 1),
dlogis(x, location = 3, scale = 3)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2",
name = "Parameters") +
labs(title = "Logistics Distributions with Different Parameters",
x = "x",
y = "Density") +
# ylim(c(0, 2)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(
legend.position = "bottom",
plot.title = element_text(hjust = 0.5),
text = element_text(size = 12)
)

ggsave("logistic_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
LaPlace Distribution
dlaplace <- function(x, mu = 0, b = 1) {
(1/(2*b)) * exp(-abs(x - mu)/b)
}
x <- seq(-5, 5, length.out = 1000)
df_data <- data.frame(x = rep(x, 6),
params = factor(rep(c("μ=0, b=0.5", "μ=0, b=1", "μ=0, b=2",
"μ=-2, b=1", "μ=2, b=1", "μ=0, b=3"),
each = length(x))),
density = c(
dlaplace(x, mu = 0, b = 0.5),
dlaplace(x, mu = 0, b = 1),
dlaplace(x, mu = 0, b = 2),
dlaplace(x, mu = -2, b = 1),
dlaplace(x, mu = 2, b = 1),
dlaplace(x, mu = 0, b = 3)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2", name = "Parameters") +
labs(title = "Laplace Distributions with Different Parameters",
x = "x", y = "Density") +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("laplace_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Cauchy Distribution
x <- seq(-10, 10, length.out = 1000)
df_data <- data.frame(x = rep(x, 6),
params = factor(rep(c("x₀=0, γ=0.5", "x₀=0, γ=1", "x₀=0, γ=2",
"x₀=-2, γ=1", "x₀=2, γ=1", "x₀=0, γ=3"),
each = length(x))),
density = c(
dcauchy(x, location = 0, scale = 0.5),
dcauchy(x, location = 0, scale = 1),
dcauchy(x, location = 0, scale = 2),
dcauchy(x, location = -2, scale = 1),
dcauchy(x, location = 2, scale = 1),
dcauchy(x, location = 0, scale = 3)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2", name = "Parameters") +
labs(title = "Cauchy Distributions with Different Parameters",
x = "x", y = "Density") +
ylim(c(0, 0.8)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("cauchy_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Pareto Distribution
x <- seq(1, 10, length.out = 1000)
df_data <- data.frame(x = rep(x, 6),
params = factor(rep(c("xₘ=1, α=1", "xₘ=1, α=2", "xₘ=1, α=3",
"xₘ=1, α=4", "xₘ=2, α=2", "xₘ=1, α=0.5"),
each = length(x))),
density = c(
dpareto(x, scale = 1, shape = 1),
dpareto(x, scale = 1, shape = 2),
dpareto(x, scale = 1, shape = 3),
dpareto(x, scale = 1, shape = 4),
dpareto(x, scale = 2, shape = 2),
dpareto(x, scale = 1, shape = 0.5)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2", name = "Parameters") +
labs(title = "Pareto Distributions with Different Parameters",
x = "x", y = "Density") +
ylim(c(0, 2)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))
## Warning: Removed 29 rows containing missing values or values outside the scale range
## (`geom_line()`).

ggsave("pareto_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
## Warning: Removed 29 rows containing missing values or values outside the scale range
## (`geom_line()`).
Weibull Distribution
x <- seq(0, 3, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
params = factor(rep(c("k=0.5, λ=1", "k=1, λ=1", "k=1.5, λ=1",
"k=2, λ=1", "k=3, λ=1", "k=5, λ=1", "k=2, λ=2"),
each = length(x))),
density = c(
dweibull(x, shape = 0.5, scale = 1),
dweibull(x, shape = 1, scale = 1),
dweibull(x, shape = 1.5, scale = 1),
dweibull(x, shape = 2, scale = 1),
dweibull(x, shape = 3, scale = 1),
dweibull(x, shape = 5, scale = 1),
dweibull(x, shape = 2, scale = 2)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2", name = "Parameters") +
labs(title = "Weibull Distributions with Different Parameters",
x = "x", y = "Density") +
ylim(c(0, 2.5)) +
guides(color = guide_legend(nrow = 1)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("weibull_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Gumbel Distribution
x <- seq(-5, 15, length.out = 1000)
df_data <- data.frame(x = rep(x, 6),
params = factor(rep(c("μ=0, β=1", "μ=0, β=2", "μ=0, β=0.5",
"μ=2, β=1", "μ=5, β=2", "μ=-2, β=1"),
each = length(x))),
density = c(
dgumbel(x, loc = 0, scale = 1),
dgumbel(x, loc = 0, scale = 2),
dgumbel(x, loc = 0, scale = 0.5),
dgumbel(x, loc = 2, scale = 1),
dgumbel(x, loc = 5, scale = 2),
dgumbel(x, loc = -2, scale = 1)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2", name = "Parameters") +
labs(title = "Gumbel Distributions with Different Parameters",
x = "x", y = "Density") +
ylim(c(0, 0.5)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("gubel_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
F-Distribution
x <- seq(0, 5, length.out = 1000)
df_data <- data.frame(x = rep(x, 7),
params = factor(rep(c("df₁=1, df₂=1", "df₁=2, df₂=1", "df₁=5, df₂=2",
"df₁=10, df₂=1", "df₁=10, df₂=10", "df₁=20, df₂=20", "df₁=50, df₂=50"),
each = length(x))),
density = c(
df(x, df1 = 1, df2 = 1),
df(x, df1 = 2, df2 = 1),
df(x, df1 = 5, df2 = 2),
df(x, df1 = 10, df2 = 1),
df(x, df1 = 10, df2 = 10),
df(x, df1 = 20, df2 = 20),
df(x, df1 = 50, df2 = 50)
))
ggplot(df_data, aes(x = x, y = density, color = params)) +
geom_line(linewidth = 1) +
scale_color_brewer(palette = "Dark2", name = "Parameters") +
labs(title = "F Distributions with Different Degrees of Freedom",
x = "x", y = "Density") +
ylim(c(0, 2)) +
guides(color = guide_legend(nrow = 2)) +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("f_distribution.png", width = 10, height = 6, units = "in", dpi = 300)
Dirichlet Distribution
set.seed(123)
n_samples <- 1000
df_data <- data.frame(
x1 = c(rdirichlet(n_samples, c(2, 2, 2))[,1],
rdirichlet(n_samples, c(5, 2, 2))[,1],
rdirichlet(n_samples, c(10, 2, 2))[,1]),
x2 = c(rdirichlet(n_samples, c(2, 2, 2))[,2],
rdirichlet(n_samples, c(5, 2, 2))[,2],
rdirichlet(n_samples, c(10, 2, 2))[,2]),
params = factor(rep(c("α=(2,2,2)", "α=(5,2,2)", "α=(10,2,2)"), each = n_samples))
)
ggplot(df_data, aes(x = x1, y = x2, color = params)) +
geom_point(alpha = 0.3, size = 0.5) +
scale_color_brewer(palette = "Dark2", name = "Alpha Parameters") +
labs(title = "Dirichlet Distribution Samples (2D Projection)",
x = "Component 1", y = "Component 2") +
theme_minimal() +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5))

ggsave("dirichlet_distribution.png", width = 10, height = 6, units = "in", dpi = 300)