# NOT RUN {
di <- uniform_distribution(lower = 1, upper = 10)
print(di)
li <- as.list(di)
di2 <- as_distribution(li)
print(di2)
# Defining a custom distribution, using the pbeta and qbeta functions
beta_distribution <- function(
shape1,
shape2,
ncp,
lower = -Inf,
upper = Inf
) {
di <- distribution(lower = lower, upper = upper, shape1, shape2, ncp)
add_class(di, beta_distribution)
}
distribution_function.beta_distribution <- function(dist) {
function(q) {
stats::pbeta(q, shape1 = dist$shape1, shape2 = dist$shape2, ncp = dist$ncp)
}
}
quantile_function.beta_distribution <- function(dist) {
function(p) {
stats::qbeta(p, shape1 = dist$shape1, shape2 = dist$shape2, ncp = dist$ncp)
}
}
# }
Run the code above in your browser using DataLab