R/starSampler.R

Defines functions starSampler

Documented in starSampler

#' A function implementing the star-sampler for the DRPT.
#'
#' A function implementing Algorithm 2 in \insertCite{BB2025DRPT;textual}{DRPT}.
#'
#' @param X A numeric vector containing the first sample.
#' @param Y A numeric vector containing the second sample.
#' @param r A function specifying the hypothesised density ratio.
#' @param H An integer specifying the number of permutations to use. Defaults to 99.
#' @param S An integer specifying the number of steps for the Markov-Chain defined in Algorithm
#' 2 in \insertCite{BB2025DRPT;textual}{DRPT}. Defaults to 50.
#'
#' @return A list of \eqn{H+1} rearrangements of the whole sample. The first element of
#' the list is the original dataset. The other \eqn{H} elements are permutations of the original
#' dataset, where permutations are generated using Algorithm 2 in the paper.
#' @export
#'
#' @references \insertRef{BB2025DRPT}{DRPT}
#'
#' @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)

starSampler = function(X, Y, r, H=99, S=50){
  return(star_sampler_C(X, Y, S, H, r))
}

Try the DRPT package in your browser

Any scripts or data that you put into this service are public.

DRPT documentation built on Aug. 8, 2025, 7:40 p.m.