Description Usage Arguments Value Examples
Calculates the mean waiting time for a special absorbing markov chain
(directed acyclic graph) that is based on an n-point-distribution. The value
of this function answers the question:
"How long do I have to wait (on average) until every
value of a discrete distribution (with a finite set of values) appears
at least once?"
Uses Rcpp
with memoization for faster calculations, but the problem
is still O(2^n): 0.2s for length(x) = 15
, and 11s
for length(x) = 20
. An approximation approach is given, see argument
"max.len"
.
1 | getWaitingTime(x, max.len = 10)
|
x |
|
max.len |
|
[numeric(1)]
Mean waiting time.
1 2 3 4 5 6 7 8 9 10 11 12 | # How long until every side of a dice appears at least once (on average)?
getWaitingTime(rep(1/6, 6))
# Approximation:
## Not run:
set.seed(1909)
tmp <- probnorm(runif(18))
system.time(print(getWaitingTime(tmp, max.len = 18)))
system.time(print(getWaitingTime(tmp, max.len = 10)))
system.time(print(getWaitingTime(tmp, max.len = 5)))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.