# msQuantile: Quantile of the multiscale statistics In essHist: The Essential Histogram

## Description

Simulate quantiles of the multiscale statistics under any continuous distribution function.

## Usage

 ```1 2``` ```msQuantile(n, alpha = c(0.5), nsim = 5e3, is.sim = (n < 1e4), intv = genIntv(n), mode = c("Con", "Gen"), ...) ```

## Arguments

 `n` number of observations. `alpha` significance level; default as 0.5, see also `essHistogram`. Like `quantile`, it can also be a vector. `nsim` numer of Monte Carlo simulations. `is.sim` logical. If `TRUE` (default if `n` < 10,000) the quantile is determined via Monte Carlo simulations, which might take a long time; otherwise (default if `n` >= 10,000) it uses the quantile with `n` = 10,000, which has been precomputed and stored. `intv` a data frame provides the system of intervals on which the multiscale statistic is defined. The data frame constains the following two columns `left` left index of an interval `right` right index of an interval By default, it is set to the sparse interval system proposed by Rivera and Walther (2013), see `genIntv` and also Li et al. (2016). `mode` `"Con"` for continuous distribution functions (default) `"Gen"` for general (possibly with discontinuous) distribution functions See Li et al. (2016) for further details. `...` further arguments passed to function `quantile`.

## Details

Empirically, it turns out that the quantile of the multiscale statistic converges fast to that of the limit distribution as the number of observations `n` increases. Thus, for the sake of computational efficiency, the quantile with `n` = 10,000 are used by default for that with `n` > 10,000, which has already been precomputed and stored. Of course, for arbitrary sample size `n`, one can always simulate the quantile by setting `is.sim = TRUE`, and use the precomputed value by setting `is.sim = FALSE`. For a given sample size `n`, simulations are once computed, and then automatically recorded in the R memory for later usage. For memory efficiency, only the last simulation is stored.

## Value

A vector of length `length(alpha)` is returned, the same structure as returned by funtion `quantile` with option `names = FALSE`; The values are the (1-`alpha`)-quantile(s) of the null distribution of the multiscale statistic via Monte Carlo simulation, corresponding to (1-`alpha`)-confidence level(s). See Li et al. (2016) for further details.

## Note

All the printing messages can be disabled by calling `suppressMessages`.

## References

Li, H., Munk, A., Sieling, H., and Walther, G. (2016). The essential histogram. arXiv:1612.07216.

Rivera, C., & Walther, G. (2013). Optimal detection of a jump in the intensity of a Poisson process or in a density with likelihood ratio statistics. Scand. J. Stat. 40, 752–769.

`checkHistogram`, `essHistogram`, `genIntv`
 ```1 2 3 4 5 6 7``` ```n = 100 # number of observations nsim = 100 # number of simulations alpha = c(0.1, 0.9) # significance level q = msQuantile(n, alpha, nsim) print(q) ```