Skip to content

Wrapper for sampling methods in R and approximate star discrepancy calculation

License

Notifications You must be signed in to change notification settings

jakobbossek/dandy

Repository files navigation

dandy: Desings ANd DiscrepancY

Status CRAN Status Badge CRAN checks CRAN Downloads

Build Status Build status Coverage Status

Introduction

This package offers a simple method for the generation of random uniform, LHS, Sobol and Halton sequences of n points in d dimension. Basically the package delegates to other packages and offers a unified interface. Additionally, an exact method and an approximate method based on threshold accepting optimization for the calculation of the star discrepancy measure is included.

Example

Here, we generate each one uniform, latin hypercube sample, Halton and Sobol design with n=20 points in k=2 dimensions and calculate its exact disrepancy.

library(dandy)
library(ggplot2)

n = 50
methods = c("uniform", "improvedlhs", "halton", "sobol")
designs = lapply(methods, function(method) {
  dandy::design(n = n, k = 5, method = method)
})

# caluclate star discrepancy
discr.exact  = sapply(designs, dandy::stardiscrepancy, method = "exact")
discr.approx = sapply(designs, dandy::stardiscrepancy, method = "ta")

# visualize
designs = do.call(rbind, designs)
groups = sprintf("%s (%.4f)", methods, discr.exact)
designs$method = factor(rep(groups, each = n))

pl = ggplot(designs, aes(x = x1, y = x2))
pl = pl + geom_point()
pl = pl + facet_grid(. ~ method)
print(pl)

Development Team

The package is a one-man project by Jakob Bossek at the moment of writing. However, the package interfaces a neat implementation of approximate star-discrepancy caluclation by Magnus Wahlström.

Gnewuch, Michael, Magnus Wahlström, and Carola Winzen. “A NEW RANDOMIZED ALGORITHM TO APPROXIMATE THE STAR DISCREPANCY BASED ON THRESHOLD ACCEPTING.” SIAM Journal on Numerical Analysis 50, no. 2 (2012): 781-807. www.jstor.org/stable/41582760.

How to contribute?

You can contribute by identifing annoying bugs in the issue tracker. This is also the preferred place to ask questions and raise feature requests. Moreover, users can contribute even more by forking the dandy repository, implementing features or bugfixes and raising a pull request.

Installation Instructions

The package will be available at CRAN when it is done. If you are interested in trying out and playing around with the current github developer version use the devtools package and type the following command in R:

remotes::install_github("jakobbossek/dandy")

Getting help

Please address questions and missing features about the dandy as weell as annoying bug reports in the issue tracker. Pay attention to explain your problem as good as possible. At its best you provide an example, so I can reproduce your problem quickly. Please avoid sending e-mails.

Releases

No releases published

Packages

No packages published