efficient_round: Efficient Round

View source: R/efficient_round.R

efficient_roundR Documentation

Efficient Round

Description

Takes an approximate design, and a number of points and converts the design to an approximate design. It uses the multiplier (n - l/2) and evens the total number of observations afterwards.

Usage

efficient_round(design, n, tol = 1e-05, seed = NULL)

Arguments

design

a dataframe with a Weight column and one or more design-variable columns (Point for single-factor designs, x1, x2, ... for multi-factor designs).

n

an integer that represents the desired number of observations of the exact design

tol

optional parameter for the consideration of an integer in the rounding process

seed

optional integer seed for reproducibility. When the rounded weights sum to less than n, a random tie-breaking step is used; supplying seed makes that step deterministic by calling set.seed(seed) immediately before it. NULL (default) leaves the global RNG state unchanged.

Value

a data.frame with the same columns as design, with Weight replaced by integer observation counts summing to n.

Examples

design_test <- data.frame("Point" = seq(1, 5, length.out = 7),
         "Weight" = c(0.1, 0.0001, 0.2, 0.134, 0.073, 0.2111, 0.2818))

efficient_round(design_test, 20)

exact_design <- efficient_round(design_test, 21)
aprox_design <- exact_design
aprox_design$Weight <- aprox_design$Weight/sum(aprox_design$Weight)

# Reproducible tie-breaking
efficient_round(design_test, 20, seed = 42)

optedr documentation built on June 23, 2026, 5:07 p.m.