Learn R Programming

DRPT (version 1.1)

starSampler: A function implementing the star-sampler for the DRPT.

Description

A function implementing Algorithm 2 in BB2025DRPT;textualDRPT.

Usage

starSampler(X, Y, r, H = 99, S = 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.

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 BB2025DRPT;textualDRPT. Defaults to 50.

References

BB2025DRPTDRPT

Examples

Run this code
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)

Run the code above in your browser using DataLab