Skip to contents

Creates independent, boundary-concentrated, or coherent-patch errors for mask-cleaning experiments.

Usage

corrupt_categorical_mask(
  mask,
  mechanism = c("impulse", "boundary", "patch"),
  rate = 0.15,
  seed = 1L
)

Arguments

mask

A reference categorical matrix or three-dimensional array.

mechanism

One of "impulse", "boundary", or "patch".

rate

Fraction of non-missing cells whose labels are replaced.

seed

One integer random seed.

Value

A mask with the same representation as mask and a reproducible set of changed labels. Exactly round(rate * n) non-missing cells are changed while at least one correct exemplar of every reference class is retained; a rate that makes this impossible is rejected.