Functions to compute center of distribution. summ_center() is a wrapper for respective summ_*() functions (from this page) with default arguments.

summ_center(f, method = "mean")

summ_mean(f)

summ_median(f)

summ_mode(f, method = "global")

Arguments

f

A pdqr-function representing distribution.

method

Method of center computation. For summ_center() is one of "mean", "median", "mode". For summ_mode() is one of "global" or "local".

Value

summ_center(), summ_mean(), summ_median() and summ_mode(*, method = "global") always return a single number representing a center of distribution. summ_mode(*, method = "local") can return a numeric vector with multiple values representing local maxima.

Details

summ_mean() computes distribution's mean.

summ_median() computes a smallest x value for which cumulative probability is not less than 0.5. Essentially, it is a as_q(f)(0.5). This also means that for pdqr-functions with type "discrete" it always returns an entry of "x" column from f's "x_tbl" metadata.

summ_mode(*, method = "global") computes a smallest x (which is an entry of "x" column from f's x_tbl) with the highest probability/density. summ_mode(*, method = "local") computes all x values which represent non-strict local maxima of probability mass/density function.

See also

Examples

# Type "continuous" d_norm <- as_d(dnorm) # The same as `summ_center(d_norm, method = "mean")` summ_mean(d_norm)
#> [1] -2.072488e-16
summ_median(d_norm)
#> [1] 0
summ_mode(d_norm)
#> [1] -2.904343e-12
# Type "discrete" d_pois <- as_d(dpois, lambda = 10) summ_mean(d_pois)
#> [1] 9.999985
summ_median(d_pois)
#> [1] 10
# Returns the smallest `x` with highest probability summ_mode(d_pois)
#> [1] 9
# Returns all values which are non-strict local maxima summ_mode(d_pois, method = "local")
#> [1] 9 10
# Details of computing local modes my_d <- new_d(data.frame(x = 11:15, y = c(0, 1, 0, 2, 0)/3), "continuous") # Several values, which are entries of `x_tbl`, are returned as local modes summ_mode(my_d, method = "local")
#> [1] 12 14