total_variation_true_exp_4: Total variation between kernel density of samples to the true...

Description Usage Arguments Value Examples

View source: R/analysis_exp_4.R

Description

This function obtains the total variation, i.e. the integral of density |pi - tildepi| / 2, where tildepi is the kernel density of the samples (note we divide by two so that this is bounded by 1)

Usage

1
total_variation_true_exp_4(samples, bw = "nrd0")

Arguments

samples

samples of exp(-(x^4)/2)

bw

bandwidth for kernel density estimation (same bw as for density())

Value

the total variation between samples and the true density, exp(-(x^4)/2)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
input_samples <- base_rejection_sampler_exp_4(beta = 1/4, nsamples = 100000,  proposal_mean = 0, proposal_sd = 1.5, dominating_M = 1.4)
test <- parallel_h_fusion_exp_4(N_schedule = rep(10000, 2), time_schedule = rep(1, 2),
                                start_beta = 1/4, C_schedule = rep(2, 2), L = 3,
                                base_samples = input_samples, study = T)

# plot true density
curve(target_density_exp_4(x), -3, 3)
# plot density of samples
lines(density(test$samples[[1]]))
# plot density of the difference between samples obtained and true density
lines(diff_density_true_exp_4(test$samples[[1]]))

# print total variation
print(total_variation_true_exp_4(test$samples))

 @export

rchan26/exp4FusionRCPP documentation built on Nov. 6, 2019, 7:01 p.m.