Skip to contents

Access the inverse of a distribution. Specifically, if X is a random variable coming from a distribution, invert() returns the distribution of 1 / X.

Usage

invert(distribution)

Arguments

distribution

A probability distribution.

Value

An inverse distribution. Specifically, a distribution with subclass "inverse".

Note

An error is returned if the original distribution has 0 as a possible outcome (i.e., eval_pmf(distribution, at = 0, strict = FALSE) is non-zero), because 0 does not have a reciprocal.

You can also obtain the inverse distribution by putting the distribution in the denominator of /.

See also

Examples

1 / (distionary::dst_pois(3.4) + 1)
#> [1] "inverse" "dst"    
#> 
#>  distribution :
#> [1] "shift" "dst"  
#> 
#>  components :
#> $distribution
#> [1] "pois"       "parametric" "dst"       
#> 
#>  name :
#> [1] "pois"
#> 
#> $shift
#> [1] 1
#> 
invert(distionary::dst_norm(0, 1))
#> [1] "inverse" "dst"    
#> 
#>  distribution :
#> [1] "norm"       "parametric" "dst"       
#> 
#>  name :
#> [1] "norm"