permute_within_bins: Internal Utility Function for Within-Bin Permutation

View source: R/ComputePermutation.R

permute_within_binsR Documentation

Internal Utility Function for Within-Bin Permutation

Description

Permutes the values of one vector within bins defined by another vector. This function is intended for internal use only and should not be accessed by package users.

The binning vector is split into evenly spaced bins between its minimum and maximum values. Values of the target vector are then randomly permuted only within each bin. This preserves the approximate relationship between the target vector and the binning variable while breaking the original sample-wise ordering within local strata.

Usage

permute_within_bins(x, y, bin = 8)

Arguments

x

A numeric vector used to define bins.

y

A vector with the same length as 'x'. Values in 'y' are permuted within bins of 'x'.

bin

An integer specifying the number of evenly spaced bins. Default is 8.

Value

A vector with the same length as 'y', where values have been permuted within bins of 'x'.


conMItion documentation built on June 17, 2026, 5:06 p.m.