get_max_coupling: Sample from maximal coupling of two distributions p and q

View source: R/get_max_coupling.R

get_max_couplingR Documentation

Sample from maximal coupling of two distributions p and q

Description

Takes two univariate continuous distributions (specified by random number generator and log-pdf function), and returns a function to sample from a maximal coupling of these two distributions.

Usage

get_max_coupling(rp, dp, rq, dq)

Arguments

rp

A function taking n as an argument and returning n samples from the distribution p

dp

A function taking x as an argument and returning log-pdf of p evaluated at x

rq

A function taking n as an argument and returning n samples from the distribution q

dq

A function taking x as an argument and returning log-pdf of q evaluated at x

Value

Returns a list with

  • "xy": the pair of samples (x,y)

  • "identical": TRUE if x = y, FALSE otherwise

Examples

mu1 <- 0; mu2 <- 1; sigma1 <- 0.5; sigma2 <- 1.2
 f <- get_max_coupling(function(n) rnorm(n, mu1, sigma1),
 function(x) dnorm(x, mu1, sigma1, log = TRUE),
 function(n) rnorm(n, mu2, sigma2),
 function(x) dnorm(x, mu2, sigma2, log = TRUE))
f()

pierrejacob/debiasedmcmc documentation built on Aug. 22, 2022, 12:41 a.m.