knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "README-"
)
options(width = 100, digits = 2)

histmatch Travis-CI Build Status

Provides a fast implementation for weighted histogram matching.

devtools::load_all(quiet = TRUE)
library(dplyr, warn.conflicts = FALSE)
requireNamespace("ggplot2", quietly = TRUE)
histmatch(1:10, 1:10)
histmatch(1:10, 2:11)
histmatch(1:11, 5:6)
histmatch(1:11, c(2, 4, 5))

In the following plot, the black and red elements correspond to the target and source distribution, respectively.

set.seed(20161031)
x_source <- runif(10)
x_source
x_target <- rnorm(30)
x_target
histmatch_data(x_source, x_target) %>% plot

Timing

For random vectors, which are generated using the following function:

r <- function(e) runif(10 ** e)
set.seed(123)
microbenchmark::microbenchmark(
  r(4),
  histmatch(r(3), r(3)),
  histmatch(r(3), r(3), r(3)),
  histmatch(r(3), r(4)),
  histmatch(r(3), r(4), r(4)),
  histmatch(r(4), r(4)),
  histmatch(r(4), r(4), r(4)),
  histmatch(r(4), r(3)),
  histmatch(r(4), r(3), r(3)),
  times = 100
) %>%
  group_by(expr) %>% 
  summarize(median_ms = median(time) / 1e6) %>% 
  ungroup

Installation

devtools::install_github("krlmlr/histmatch")


krlmlr/histmatch documentation built on May 10, 2019, 6 a.m.