The previous tutorial we looked at how wrappers are used to extend functionality in distr6 to composite and transformed distributions. Now we will take a slight detour from the distribution interface to look at symbolic sets and intervals. We will keep this tutorial brief as whilst these objects form an integral part of making distr6 have pretty print methods, they are purely symbolic and have little mathematical functionality.

The class structure for these objects looks like: `SetInterval -> Set`

, `SetInterval -> Interval`

i.e. everything inherits from `SetInterval`

, this means all methods from `SetInterval`

are also in `Set`

and `Interval`

objects. Sets and intervals primarily differ in that sets expect discrete elements whereas intervals expect a range of numerics:

The type of interval can be changed to ensure the correct bounds are set

```
Interval$new(-Inf, Inf, type = "()")
#> [1] "(-∞,+∞)"
Interval$new(-Inf, 10, type = "(]")
#> [1] "(-∞,10]"
Interval$new(1, Inf, type = "[)")
#> [1] "[1,+∞)"
Interval$new(1, 10, type = "[]")
#> [1] "[1,10]"
```

These also include basic accessors for the bounds of the interval

```
Interval$new(0,10,type = "()")$min()
#> [1] 1.1e-15
Interval$new(0,10,type = "()")$inf()
#> [1] 0
Interval$new(0,10,type = "()")$max()
#> [1] 10
#10 - 1.1e-15
Interval$new(0,10,type = "()")$sup()
#> [1] 10
```

And a way of testing if an element lies in the set or interval

distr6 includes some sets which are especially special, these can be listed with

```
listSpecialSets()
#> ClassName Symbol Infimum Supremum
#> 1: Empty ∅ NULL NULL
#> 2: Naturals ℕ0 0 Inf
#> 3: PosNaturals ℕ+ 0/1 Inf
#> 4: Integers ℤ -Inf Inf
#> 5: PosIntegers ℤ+ 0/1 Inf
#> 6: NegIntegers ℤ- -Inf -1/0
#> 7: Rationals ℚ -Inf Inf
#> 8: PosRationals ℚ+ 0/1 Inf
#> 9: NegRationals ℚ- -Inf -1/0
#> 10: Reals ℝ -Inf Inf
#> 11: PosReals ℝ+ 0/1 Inf
#> 12: NegReals ℝ- -Inf -1/0
#> 13: ExtendedReals ℝ ∪ {-∞, +∞} -Inf Inf
#> 14: Complex ℂ -Inf Inf
```

And are constructed like any class

Note: We don’t have one set for non-negative and another for positive, this is determined by the `zero`

argument

We have kept this very short as these are primarily meant to be used internally. We encourage you to look at the help pages in the documentation if you are interested in learning about sets further. In the next and final tutorial we conclude with running through how to construct your own custom distribution.