View source: R/probability_tools.R
| dfitverse | R Documentation |
Convenience functions that evaluate the probability density function (PDF),
cumulative distribution function (CDF), quantile function (inverse CDF),
and random-number generator for the best-fit distribution stored in a
fitverse object.
These follow the standard R d/p/q/r naming convention and delegate to
the underlying d*, p*, q*, and r* functions
for the best-fit distribution.
dfitverse(x, fit, log = FALSE)
pfitverse(q, fit, lower.tail = TRUE, log.p = FALSE)
qfitverse(p, fit, lower.tail = TRUE, log.p = FALSE)
rfitverse(n, fit)
x |
Numeric vector of quantiles at which to evaluate the density. |
q |
Numeric vector of quantiles at which to evaluate the CDF. |
p |
Numeric vector of probabilities |
n |
Integer: number of random samples to generate. |
fit |
An object of class |
log, log.p |
Logical: if |
lower.tail |
Logical: if |
The correct d/p/q/r functions are resolved via .lookup_dpqr(),
which follows a two-step priority:
Internal closed-form implementations (highest priority):
GEV, Gumbel, GPD, Pearson III, Log-Pearson III, and GLO all use
FitVerse's own vectorised implementations registered in
.FITVERSE_DPQR_OVERRIDES. This avoids any package-version
signature issues with evd and provides full support for the
new hydrological distributions that have no dedicated CRAN d/p/q/r
package.
Package namespace lookup: For all other distributions,
stats functions are found via match.fun(); Imports/Suggests
packages (actuar, sn, mc2d) are resolved via
getExportedValue().
The estimated parameters are extracted from fit$best_fit$params
and passed as named arguments to the underlying function. This is
equivalent to calling, for example,
dgamma(x, shape = fit$best_fit$params["shape"], rate = fit$best_fit$params["rate"]).
dfitverse()Numeric vector of density values.
pfitverse()Numeric vector of probabilities.
qfitverse()Numeric vector of quantiles.
rfitverse()Numeric vector of random samples.
Karuna G. Reddy karuna.reddy@auckland.ac.nz
M. G. M. Khan mgm.khan@usp.ac.fj
return_level for T-year return levels.
fitverse for the fitting step.
set.seed(42)
x <- rgamma(300, shape = 2, rate = 0.5)
fit <- fitverse(x, dists = "gamma", plot = FALSE, verbose = FALSE)
# Density at x = 2
dfitverse(2, fit)
# Probability that X <= 5
pfitverse(5, fit)
# 90th percentile
qfitverse(0.90, fit)
# Generate 10 random samples
rfitverse(10, fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.