prob_fun_mc: Q-values for Scan Statistics by Monte Carlo Simulation

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/prob_fun_mc.R

Description

This function returns the scan statistics q-value which is approximated by Monte Carlo simulation.

Usage

1
prob_fun_mc(N,k,m,p,mc_rep)

Arguments

N

number of Bernoulli trials.

k

a number or numeric vector represents scan statistics quantile(s).

m

scan statistics window length.

p

success probabiliy for each Bernoulli trial under null hypothesis.

mc_rep

number of replications.

Details

It has been proved that calculate excat scan statistics probability is a NP hard problem. Thus, a straightway to solve this problem is using Monte Carlo simulation. As mc_rep getting larger, the result will be closer to the true value but a longer time it will take to obtain the result. This is a tradeoff between accuracy and efficiency.

N, m, mc_rep are all integers, where m > 0, 0 ≤ min(k) ≤ max(k) ≤ m and N/m > 5.
p is a real number where 0 < p ≤ 1.

Value

This function returns the approximated q-value.

Author(s)

Zhicong Zhao

See Also

prob_fun which approximate q-value by 1-dependent stationary sequences.

Examples

1
2
3
4
## estimate running time ##
set.seed(100)
system.time({q_value <- prob_fun_mc(1000,4:6,10,0.1,10000)})
q_value

zhicongz/AnomDetct documentation built on Dec. 12, 2019, 9:16 a.m.