Skip to contents
  • units() retrieves the value of the units slot.

  • generate() randomly samples values from the distributional properties of the variable.

  • parameters() returns the parameters that define variable's distribution.

Usage

# S4 method for class 'VarDist'
distr(x)

# S4 method for class 'VarDist'
units(x)

# S4 method for class 'VarDist'
generate(x, times = 1)

# S4 method for class 'VarDist'
parameters(x)

Arguments

x

an object of class <VarDist>.

times

the sample size.

Examples


# create a VarDist object
speed <- VarDist(dist_normal(10, 0.5), "m/s")

# get slot `units`
units(speed)
#> [1] "m/s"

# get slot `distr`
distr(speed)
#> <distribution[1]>
#> [1] N(10, 0.25)

# generate 100 random values from the variable's probability distribution
generate(speed, times = 100)
#> Error in UseMethod("generate"): no applicable method for 'generate' applied to an object of class "VarDist"

# parameters underpinning Normally distributed `speed`
parameters(speed)
#> Error in UseMethod("parameters"): no applicable method for 'parameters' applied to an object of class "VarDist"