knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(distplyr)
The graft distributions are a family of distributions containing the cumulative distribution function of a base distribution, along with the cdf distribution of prespecified right/left distribution grafted onto the cdf distribution along the base. Scaling must be done to the grafted distribution in order to ensure the cdf does not exceed 1, and to ensure the distribution is continuous along the grafting point. The distributions used can be of any type, discrete, contentious, and mixed, and can be intermixed to create various distributions.
A graft distribution is created using the graft_left(), graft_right()
functions. graft_right()
keeps the cdf to the left of left_at unchanged, while adding a continuous, scaled connection to the right cdf. graft_right
keeps the cdf to the right of right_at unchanged, while adding a continuous, scaled connection to the left cdf. Both functions can be used in tandem to create a distribution which is both left and right grafted.
require(datasets) norm_base <- dst_norm(0, 1) fin_right <- dst_finite(1:5, probs = rep(0.2, 5)) right_grafted <- graft_right(norm_base, fin_right, 1, include_at = TRUE) # Creates a right grafted distribution with the base ditribution being norm_base, # and the grafted distribution being fin_right. The point at which fin_right is # grafted at is 1. gpd_base <- dst_gpd(1, 2, 3) mix_left <- mix( dst_empirical(hp, data = mtcars), dst_norm(1, 2) ) left_grafted <- graft_left(gpd_base, mix_left, 52, include_at = FALSE) # Creates a right grafted distribution with the base ditribution being gpd_base, # and the grafted distribution being mix_left. The point at which gpd is grafted # at is 52.
Graft distributions can be used for a multitude of reasons, with one being distribution interpolation. If it is assumed that a discrete distribution, such as an empirical distribution, is used as the base distribution, it is difficult to interpolate data from in between points, especially towards the higher and lower extremities since the cdf will proceed directly to 1. As such, if we use a graft distribution, we can substitute another distribution, such as a generalized Pareto distribution, towards the ends of the distribution to make more realistic interpolations.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.