probing.Rmd
library(distplyr)
One purpose of distplyr
is to handle the menial distributionrelated calculations for you. Just specify a distribution once, and there is no need to manage its components anymore.
A distribution can be represented by different functions. In distplyr
, you can:
eval_*
;enframe_*
; orget_*
.Here are the representations and the corresponding distplyr
functions:
Quantity 
distplyr Functions 

Cumulative Distribution Function 
eval_cdf() , get_cdf() , enframe_cdf()

Survival Function 
eval_survival() , get_survival() , enframe_survival()

Quantile Function 
eval_quantile() , get_quantile() , enframe_quantile()

Hazard Function 
eval_hazard() , get_hazard() , enframe_hazard()

Cumulative Hazard Function 
eval_chf() , get_chf() , enframe_chf()

Probability density function 
eval_density() , get_density() , enframe_density()

Probability mass function 
eval_pmf() , get_pmf() , enframe_pmf()

Random sample generator 
realise() , realize()

These functions all take a distribution object as their first argument, and eval_*
and enframe_*
have a second argument named at
indicating where to evaluate the function. The at
argument is vectorized.
Note that all of the stats::p*/d*/q*/r*
functions are included in this list of representations, except for the r
functions (such as rnorm()
, rpois()
, etc.). These r
functions generate a random sample, which cannot be used to reconstruct a distribution exactly, and are therefore omitted in the list of representations. Instead, use the realise()
or realize()
function.
Here is an example of evaluating the hazard function and the random sample generator of a Uniform(0,1) distribution:
d < dst_unif(0, 3)
eval_hazard(d, at = 0:10)
## [1] 0.3333333 0.5000000 1.0000000 Inf NaN NaN NaN
## [8] NaN NaN NaN NaN
## [1] 1.5224346 0.9203055 1.2807230 2.0793062 0.2554079
Distributions have various numeric properties. Common examples are the mean and variance, but there are many others as well.
Below is a table of the properties incorporated in distplyr
:
Property 
distplyr Function 

Mean  get_mean() 
Median  get_median() 
get_mode() 

Variance  get_variance() 
Standard Deviation  get_sd() 
get_iqr() 

get_entropy() 

Skewness  get_skewness() 
Excess Kurtosis  get_kurtosis_exc() 
Kurtosis  get_kurtosis_raw() 
Extreme Value (Tail) Index  get_evi() 
Here are some properties of a certain mixture of Gaussians:
## [1] 4
get_sd(m)
## [1] 2.236068
get_evi(m)
## [1] 0