The exponential distribution is commonly used to model the time between events in a Poisson process. It is defined by a single parameter rate (Ī») which is the reciprocal of the mean.
# Set seed for reproducibility
set.seed(123)
# Generate 3000 random values from an exponential distribution with rate = 1
exp_data <- rexp(3000, rate = 1)
# Calculate the 75th percentile
percentile_75 <- quantile(exp_data, 0.75)
# Print the result
cat("The 75th percentile of the exponential distribution is:", round(percentile_75, 4), "\n")
## The 75th percentile of the exponential distribution is: 1.4092
hist(exp_data)
The t-distribution (Studentās t-distribution) is used instead of the normal distribution when the sample size is small and/or the population standard deviation is unknown. Itās characterized by its degrees of freedom (df) ā lower degrees of freedom result in heavier tails
# Set seed for reproducibility
set.seed(456)
# Generate 7000 random numbers from a t-distribution with 10 degrees of freedom
t_data <- rt(7000, df = 10)
# Calculate the 95th percentile
percentile_95 <- quantile(t_data, 0.95)
# Print the result
cat("The 95th percentile of the t-distribution is:", round(percentile_95, 4), "\n")
## The 95th percentile of the t-distribution is: 1.763
hist(t_data)
A uniform distribution is a type of probability distribution where all values between a specified minimum and maximum are equally likely. In R, the function to generate data from a uniform distribution is:
# Set seed for reproducibility
set.seed(789)
# Generate 1000 random numbers from a uniform distribution between 0 and 1
uniform_data <- runif(1000000, min = 0, max = 1)
# Calculate the 67th percentile
percentile_67 <- quantile(uniform_data, 0.67)
# Print the result
cat("The 67th percentile of the uniform distribution is:", round(percentile_67, 4), "\n")
## The 67th percentile of the uniform distribution is: 0.6697
plot(density(uniform_data))
The Weibull distribution is a continuous probability distribution used in reliability analysis and survival modeling. It has two parameters: shape (š) ā defines the distributionās shape scale (Ī») ā stretches or shrinks the distribution
# Set seed for reproducibility
set.seed(1010)
# Generate 8000 random numbers from a Weibull distribution
# Using shape = 2, scale = 1 as common values
weibull_data <- rweibull(8000, shape = 2, scale = 1)
# Calculate the 75th percentile
percentile_75 <- quantile(weibull_data, 0.75)
# Print the result
cat("The 75th percentile of the Weibull distribution is:", round(percentile_75, 4), "\n")
## The 75th percentile of the Weibull distribution is: 1.1815
hist(weibull_data)
The Gamma distribution is a continuous distribution often used to model waiting times or lifetimes of events. Itās defined by: shape (α) ā sometimes denoted as k scale (Īø) ā also referred to as 1/Ī» (inverse of rate)
# Set seed for reproducibility
set.seed(1111)
# Generate 2000 random numbers from a Gamma distribution
# Using shape = 3 and scale = 2
gamma_data <- rgamma(2000, shape = 3, scale = 2)
# Calculate the 99th percentile
percentile_99 <- quantile(gamma_data, 0.99)
# Print the result
cat("The 99th percentile of the Gamma distribution is:", round(percentile_99, 4), "\n")
## The 99th percentile of the Gamma distribution is: 16.6895
hist(gamma_data)
The Poisson distribution models the number of events occurring within a fixed interval of time or space. It is defined by: Ī» (lambda) = the average number of occurrences (also called the rate)
# Set seed for reproducibility
set.seed(2025)
# Generate 10,000 random numbers from a Poisson distribution with lambda = 4
poisson_data <- rpois(10000, lambda = 4)
# Calculate the 90th percentile
percentile_90 <- quantile(poisson_data, 0.90)
# Print the result
cat("The 90th percentile of the Poisson distribution is:", percentile_90, "\n")
## The 90th percentile of the Poisson distribution is: 7
hist(poisson_data)