starSampler {DRPT} | R Documentation |
A function implementing the star-sampler for the DRPT.
Description
A function implementing Algorithm 2 in Bordino and Berrett (2025).
Usage
starSampler(X, Y, r, H = 99, S = 50)
Arguments
X |
A numeric vector containing the first sample. |
Y |
A numeric vector containing the second sample. |
r |
A function specifying the hypothesised density ratio. |
H |
An integer specifying the number of permutations to use. Defaults to 99. |
S |
An integer specifying the number of steps for the Markov-Chain defined in Algorithm 2 in Bordino and Berrett (2025). Defaults to 50. |
Value
A list of H+1
rearrangements of the whole sample. The first element of
the list is the original dataset. The other H
elements are permutations of the original
dataset, where permutations are generated using Algorithm 2 in the paper.
References
Bordino A, Berrett TB (2025). “Density Ratio Permutation Tests with connections to distributional shifts and conditional two-sample testing.” arXiv:2505.24529, https://arxiv.org/abs/2505.24529.
Examples
n = 250; m = n
r = function(x,y) {
return(4*x*y)
}
X = as.matrix(cbind(runif(n, 0, 1), runif(n, 0, 1)))
Y = as.matrix(cbind(rbeta(m, 0.5, 0.3), rbeta(m, 0.5, 0.4)))
starSampler(X, Y, r, H = 3, S = 20)