Skip to contents

The union \(\bigcup_i \Theta_{0i}\) of finitely many convex_regions, e.g. a null hypothesis or a truncated prior's support. It is not a convex_region, so has no chart() or project(); algorithms run over its parts() or cells() instead. Given exactly one convex region, union_region() returns it unchanged.

format() gives the same summary on one line.

Usage

union_region(...)

Arguments

...

convex_region objects, other union_region objects, and lists of either, in any combination and any nesting. A union_region argument flattens rather than nests.

Value

A union_region, or the lone convex_region it was given.

Properties

parts

The flat list of convex cells, as declared.

See also

region_algebra for the set-operation operators: x | y forwards to this constructor, while x & y and x - y compute new regions from old.

Examples

# The K = 3 plurality null: two overlapping sub-simplices.
union_region(
  simplex_region(vertices = rbind(c(0.5, 0.5, 0), c(0, 1, 0), c(0, 0, 1))),
  simplex_region(vertices = rbind(c(0.5, 0, 0.5), c(0, 1, 0), c(0, 0, 1)))
)
#> <union_region>
#>   2 parts, dimension 3
#>     simplex_region: 3 vertices in R^3
#>     simplex_region: 3 vertices in R^3

# Nesting is flattened, so these agree:
s <- simplex_region(vertices = diag(3))
h <- halfspace_region(normal = c(1, -1, 0))
length(parts(union_region(s, h)))
#> [1] 2
length(parts(union_region(list(s, h))))
#> [1] 2
length(parts(union_region(union_region(s), list(h))))
#> [1] 2

# One cell is already a region, so it is handed back as it came:
identical(union_region(s), s)
#> [1] TRUE