Dear R users,
the help for findInterval(x,vec) suggests a logarithmic dependence on N
(=length(vec)), which would imply a binary search type algorithm.
However, when I "test" this hypothesis, in the following manner:

set.seed(-3645);
l <- vector();
N.seq <- c(5000, 500000, 1000000, 10000000, 50000000);k <- 1
for (N in N.seq){
  tmp <- sort(round(stats::rt(N, df=2), 2));
  l[k] <- system.time(it3 <- findInterval(-1, tmp))[2];k <- k + 1;
}
plot(N.seq,l,type="b",xlab="length(vec)", ylab="CPU time");

the resulting plot suggests a linear relationship.
I must be missing sth. here ?

Thanks !

Markus

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to