[R] Comparison of the amount of computation
helin_susam
helin.susam at gmail.com
Thu Apr 14 01:12:39 CEST 2011
Hi dear list,
I want to compare the amount of computation of two functions. For example,
by using this algorithm;
data <- rnorm(n=100, mean=10, sd=3)
output1 <- list ()
for(i in 1:100) {
data1 <- sample(100, 100, replace = TRUE)
statistic1 <- mean(data1)
output1 <- c(output1, list(statistic1))
}
output1
output2 <- list()
for(i in 1:100) {
data2 <- unique(sample(100, 100, replace=TRUE))
statistic2 <- mean(data2)
output2 <- c(output2, list(statistic2))
}
output2
data1 consists of exactly 100 elements, but data2 consists of roughly 55 or
60 elements. So, to get statistic1, for each sample, 100 data points are
used. But, to get statistic2 roughly half of them are used.
I want to proof this difference. Is there any way to do this ? May be R has
a property about this process such as Rprof, i tried use but i could not
sure.
Thans for any help !
Regards,
Helin.
--
View this message in context: http://r.789695.n4.nabble.com/Comparison-of-the-amount-of-computation-tp3448436p3448436.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list