Skip to contents

A step of the momento_native implementation. No other function in the package calls it. See the file header for the source the module follows. the source it follows.

Usage

momento_reconstruction_curve(patches, reconstructor, rates, seed = 0)

Arguments

patches

Iterated over elementwise, with lapply.

reconstructor

Function (masked, mask) returning the reconstructed patches.

rates

See Usage.

seed

Passed to set.seed. Defaults to 0.

Value

A list with curve, n_patches, rates, mse.

Examples

set.seed(9)
p <- lapply(1:8, function(i) rnorm(4))
# a naive reconstructor: fill every masked patch with the mean of the visible ones
fill_mean <- function(masked, mask) {
  m <- Reduce(`+`, masked[mask == 0]) / sum(mask == 0)
  lapply(seq_along(masked), function(i) if (mask[i] == 1) m else masked[[i]])
}
momento_reconstruction_curve(p, fill_mean, rates = c(0.25, 0.5), seed = 1)$mse
#> [1] 0.5409357 1.3209131