colRowMads - HenrikBengtsson/matrixStats GitHub Wiki
matrixStats: Benchmark report
This report benchmark the performance of colMads() and rowMads() against alternative methods.
- apply() + mad()
- colMads2() and rowMads2()
where rowMads2() and colMads2() are:
> rowMads2 <- function(x, const = 1.4826, na.rm = FALSE) {
+ mu <- rowMedians(x, na.rm = na.rm)
+ x <- abs(x - mu)
+ mad <- rowMedians(x, na.rm = FALSE)
+ const * mad
+ }
> colMads2 <- function(x, const = 1.4826, na.rm = FALSE) {
+ mu <- colMedians(x, na.rm = na.rm)
+ x <- abs(x - mu)
+ mad <- colMedians(x, na.rm = FALSE)
+ const * mad
+ }> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100,
+ +100), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)> X <- data[["10x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132701 167.4 5709258 305.0 5709258 305.0
Vcells 6024971 46.0 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131392 167.3 5709258 305.0 5709258 305.0
Vcells 6021261 46.0 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on integer+10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.002657 | 0.0032760 | 0.0044315 | 0.0037815 | 0.0054525 | 0.016511 |
| 2 | colMads2 | 0.004838 | 0.0056005 | 0.0083407 | 0.0069845 | 0.0096515 | 0.074925 |
| 3 | apply+mad | 0.489800 | 0.4961660 | 0.5043725 | 0.4998120 | 0.5051165 | 0.794902 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.820851 | 1.709554 | 1.882139 | 1.847018 | 1.770106 | 4.537884 |
| 3 | apply+mad | 184.343244 | 151.454823 | 113.815297 | 132.172947 | 92.639432 | 48.143783 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on integer+10x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.002624 | 0.0032910 | 0.0044554 | 0.0042900 | 0.0055395 | 0.015129 |
| 2 | rowMads2 | 0.004901 | 0.0057515 | 0.0083339 | 0.0067125 | 0.0093310 | 0.078219 |
| 3 | apply+mad | 0.489703 | 0.4945235 | 0.5008538 | 0.4989825 | 0.5020105 | 0.660943 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.867759 | 1.747645 | 1.870525 | 1.564685 | 1.684448 | 5.170137 |
| 3 | apply+mad | 186.624619 | 150.265421 | 112.415768 | 116.312937 | 90.623793 | 43.687157 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on integer+10x10 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on integer+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 2.657 | 3.276 | 4.43150 | 3.7815 | 5.4525 | 16.511 |
| 2 | rowMads | 2.624 | 3.291 | 4.45537 | 4.2900 | 5.5395 | 15.129 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.00000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.0000000 |
| 2 | rowMads | 0.98758 | 1.004579 | 1.005386 | 1.13447 | 1.015956 | 0.9162982 |
Figure: Benchmarking of colMads() and rowMads() on integer+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3129993 167.2 5709258 305.0 5709258 305.0
Vcells 5638000 43.1 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3129984 167.2 5709258 305.0 5709258 305.0
Vcells 5643038 43.1 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on integer+100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.254314 | 0.257135 | 0.2647929 | 0.259611 | 0.2638700 | 0.355772 |
| 2 | colMads2 | 0.304025 | 0.306380 | 0.3141236 | 0.311071 | 0.3143015 | 0.388808 |
| 3 | apply+mad | 5.267928 | 5.362917 | 5.7038597 | 5.439201 | 5.6298310 | 13.697193 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.195471 | 1.191514 | 1.186299 | 1.19822 | 1.191123 | 1.092857 |
| 3 | apply+mad | 20.714267 | 20.856426 | 21.540835 | 20.95135 | 21.335624 | 38.499918 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on integer+100x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.255069 | 0.2574295 | 0.2762096 | 0.2625025 | 0.2787125 | 0.409516 |
| 2 | rowMads2 | 0.303053 | 0.3080525 | 0.3374374 | 0.3154135 | 0.3536560 | 0.535297 |
| 3 | apply+mad | 5.262654 | 5.3568480 | 6.0354499 | 5.4781915 | 5.8985855 | 24.659333 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.188122 | 1.196648 | 1.221671 | 1.201564 | 1.268892 | 1.307146 |
| 3 | apply+mad | 20.632276 | 20.808990 | 21.850977 | 20.869102 | 21.163692 | 60.215799 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on integer+100x100 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on integer+100x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 254.314 | 257.1350 | 264.7929 | 259.6110 | 263.8700 | 355.772 |
| 2 | rowMads | 255.069 | 257.4295 | 276.2096 | 262.5025 | 278.7125 | 409.516 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads | 1.002969 | 1.001145 | 1.043116 | 1.011138 | 1.056249 | 1.151063 |
Figure: Benchmarking of colMads() and rowMads() on integer+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3130750 167.3 5709258 305.0 5709258 305.0
Vcells 5641790 43.1 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3130741 167.2 5709258 305.0 5709258 305.0
Vcells 5646828 43.1 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on integer+1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.184453 | 0.1861725 | 0.1888632 | 0.1873755 | 0.1886520 | 0.245527 |
| 2 | colMads2 | 0.277145 | 0.2804365 | 0.2842387 | 0.2830035 | 0.2861835 | 0.340478 |
| 3 | apply+mad | 0.913187 | 0.9458865 | 0.9767638 | 0.9601225 | 0.9776690 | 1.676612 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.502524 | 1.506326 | 1.504998 | 1.510355 | 1.516992 | 1.386723 |
| 3 | apply+mad | 4.950784 | 5.080699 | 5.171807 | 5.124056 | 5.182394 | 6.828626 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on integer+1000x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.185629 | 0.1875140 | 0.1927187 | 0.188521 | 0.189528 | 0.321136 |
| 2 | rowMads2 | 0.288223 | 0.2909350 | 0.2999250 | 0.294080 | 0.297951 | 0.478456 |
| 3 | apply+mad | 0.917978 | 0.9488795 | 0.9638069 | 0.961623 | 0.971357 | 1.130334 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.552683 | 1.551538 | 1.556284 | 1.559932 | 1.572069 | 1.489886 |
| 3 | apply+mad | 4.945229 | 5.060313 | 5.001108 | 5.100880 | 5.125137 | 3.519798 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on integer+1000x10 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on integer+1000x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 184.453 | 186.1725 | 188.8632 | 187.3755 | 188.652 | 245.527 |
| 2 | rowMads | 185.629 | 187.5140 | 192.7187 | 188.5210 | 189.528 | 321.136 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads | 1.006376 | 1.007206 | 1.020414 | 1.006113 | 1.004644 | 1.307946 |
Figure: Benchmarking of colMads() and rowMads() on integer+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["10x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3130955 167.3 5709258 305.0 5709258 305.0
Vcells 5642227 43.1 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3130946 167.3 5709258 305.0 5709258 305.0
Vcells 5647265 43.1 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on integer+10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.255947 | 0.261325 | 0.2772449 | 0.2703955 | 0.2844750 | 0.393180 |
| 2 | colMads2 | 0.335967 | 0.341338 | 0.3611214 | 0.3587415 | 0.3705975 | 0.427025 |
| 3 | apply+mad | 47.194238 | 48.185322 | 51.4521724 | 50.0800570 | 55.5677890 | 66.438729 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
| 2 | colMads2 | 1.312643 | 1.306182 | 1.302536 | 1.326729 | 1.302742 | 1.08608 |
| 3 | apply+mad | 184.390667 | 184.388489 | 185.583830 | 185.210394 | 195.334525 | 168.97790 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on integer+10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.256452 | 0.2630255 | 0.2824898 | 0.2747510 | 0.2907425 | 0.429573 |
| 2 | rowMads2 | 0.334503 | 0.3401210 | 0.3665499 | 0.3659265 | 0.3743685 | 0.455155 |
| 3 | apply+mad | 46.956961 | 48.0190850 | 51.5078001 | 49.7054005 | 55.4881420 | 73.527768 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.304349 | 1.29311 | 1.297568 | 1.331848 | 1.287629 | 1.059552 |
| 3 | apply+mad | 183.102339 | 182.56437 | 182.335053 | 180.910717 | 190.849779 | 171.164780 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on integer+10x1000 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on integer+10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 255.947 | 261.3250 | 277.2449 | 270.3955 | 284.4750 | 393.180 |
| 2 | rowMads | 256.452 | 263.0255 | 282.4898 | 274.7510 | 290.7425 | 429.573 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads | 1.001973 | 1.006507 | 1.018918 | 1.016108 | 1.022032 | 1.092561 |
Figure: Benchmarking of colMads() and rowMads() on integer+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131168 167.3 5709258 305.0 5709258 305.0
Vcells 5643284 43.1 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131159 167.3 5709258 305.0 5709258 305.0
Vcells 5693322 43.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on integer+100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 2.513881 | 2.520923 | 2.554454 | 2.527376 | 2.543119 | 3.162973 |
| 2 | colMads2 | 2.990316 | 2.998620 | 3.050823 | 3.010641 | 3.040930 | 3.719616 |
| 3 | apply+mad | 52.309831 | 53.302986 | 57.235065 | 54.982971 | 56.280015 | 70.871133 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.189522 | 1.189493 | 1.194315 | 1.191212 | 1.195748 | 1.175987 |
| 3 | apply+mad | 20.808396 | 21.144230 | 22.405986 | 21.754967 | 22.130307 | 22.406493 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on integer+100x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 2.526592 | 2.537675 | 2.593953 | 2.574283 | 2.618336 | 3.079292 |
| 2 | rowMads2 | 3.009855 | 3.030975 | 3.152807 | 3.087254 | 3.134653 | 4.086106 |
| 3 | apply+mad | 52.563452 | 53.394471 | 57.644265 | 54.967650 | 59.456479 | 80.694532 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.191271 | 1.19439 | 1.215445 | 1.199267 | 1.197193 | 1.326963 |
| 3 | apply+mad | 20.804092 | 21.04070 | 22.222552 | 21.352606 | 22.707734 | 26.205547 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on integer+100x1000 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on integer+100x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 2.513881 | 2.520923 | 2.554454 | 2.527376 | 2.543119 | 3.162973 |
| 2 | rowMads | 2.526592 | 2.537675 | 2.593953 | 2.574283 | 2.618336 | 3.079292 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.0000000 |
| 2 | rowMads | 1.005056 | 1.006645 | 1.015463 | 1.01856 | 1.029576 | 0.9735436 |
Figure: Benchmarking of colMads() and rowMads() on integer+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131380 167.3 5709258 305.0 5709258 305.0
Vcells 5643972 43.1 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131371 167.3 5709258 305.0 5709258 305.0
Vcells 5694010 43.5 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on integer+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.964928 | 1.976131 | 2.035427 | 1.988864 | 2.039416 | 2.574327 |
| 2 | colMads2 | 2.687930 | 2.720924 | 2.951148 | 2.739002 | 2.779851 | 10.550021 |
| 3 | apply+mad | 8.982251 | 9.088460 | 9.569613 | 9.228782 | 9.519751 | 18.326280 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.367953 | 1.376894 | 1.449892 | 1.377169 | 1.363063 | 4.098167 |
| 3 | apply+mad | 4.571288 | 4.599118 | 4.701526 | 4.640227 | 4.667881 | 7.118862 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on integer+1000x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.991208 | 1.998725 | 2.047768 | 2.006607 | 2.022423 | 3.051313 |
| 2 | rowMads2 | 2.758968 | 2.793220 | 2.919762 | 2.830482 | 2.870141 | 4.087703 |
| 3 | apply+mad | 8.972996 | 9.070293 | 12.046898 | 9.141897 | 9.431546 | 250.482552 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.385575 | 1.397501 | 1.425826 | 1.410581 | 1.419160 | 1.339654 |
| 3 | apply+mad | 4.506308 | 4.538041 | 5.882940 | 4.555897 | 4.663488 | 82.090088 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on integer+1000x100 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on integer+1000x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.964928 | 1.976131 | 2.035427 | 1.988864 | 2.039416 | 2.574327 |
| 2 | rowMads | 1.991208 | 1.998725 | 2.047768 | 2.006607 | 2.022423 | 3.051313 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000000 | 1.000000 |
| 2 | rowMads | 1.013375 | 1.011433 | 1.006063 | 1.008921 | 0.9916677 | 1.185286 |
Figure: Benchmarking of colMads() and rowMads() on integer+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> rmatrix <- function(nrow, ncol, mode = c("logical", "double", "integer", "index"), range = c(-100,
+ +100), na_prob = 0) {
+ mode <- match.arg(mode)
+ n <- nrow * ncol
+ if (mode == "logical") {
+ x <- sample(c(FALSE, TRUE), size = n, replace = TRUE)
+ } else if (mode == "index") {
+ x <- seq_len(n)
+ mode <- "integer"
+ } else {
+ x <- runif(n, min = range[1], max = range[2])
+ }
+ storage.mode(x) <- mode
+ if (na_prob > 0)
+ x[sample(n, size = na_prob * n)] <- NA
+ dim(x) <- c(nrow, ncol)
+ x
+ }
> rmatrices <- function(scale = 10, seed = 1, ...) {
+ set.seed(seed)
+ data <- list()
+ data[[1]] <- rmatrix(nrow = scale * 1, ncol = scale * 1, ...)
+ data[[2]] <- rmatrix(nrow = scale * 10, ncol = scale * 10, ...)
+ data[[3]] <- rmatrix(nrow = scale * 100, ncol = scale * 1, ...)
+ data[[4]] <- t(data[[3]])
+ data[[5]] <- rmatrix(nrow = scale * 10, ncol = scale * 100, ...)
+ data[[6]] <- t(data[[5]])
+ names(data) <- sapply(data, FUN = function(x) paste(dim(x), collapse = "x"))
+ data
+ }
> data <- rmatrices(mode = mode)> X <- data[["10x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131593 167.3 5709258 305.0 5709258 305.0
Vcells 5759841 44.0 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131575 167.3 5709258 305.0 5709258 305.0
Vcells 5759964 44.0 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on double+10x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.003801 | 0.0044480 | 0.0056274 | 0.0049490 | 0.0067115 | 0.015706 |
| 2 | colMads2 | 0.005656 | 0.0067715 | 0.0085405 | 0.0075000 | 0.0104310 | 0.018714 |
| 3 | apply+mad | 0.485854 | 0.4896665 | 0.4963663 | 0.4921185 | 0.4976315 | 0.652929 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.488029 | 1.52237 | 1.517669 | 1.515458 | 1.554198 | 1.191519 |
| 3 | apply+mad | 127.822678 | 110.08689 | 88.205260 | 99.437967 | 74.146092 | 41.571947 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on double+10x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.003791 | 0.0045280 | 0.0058049 | 0.0055455 | 0.0069305 | 0.017857 |
| 2 | rowMads2 | 0.005806 | 0.0066775 | 0.0085909 | 0.0075240 | 0.0100935 | 0.020012 |
| 3 | apply+mad | 0.481752 | 0.4886720 | 0.5048879 | 0.4922790 | 0.4976600 | 1.082850 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.531522 | 1.474713 | 1.479935 | 1.356776 | 1.456388 | 1.120681 |
| 3 | apply+mad | 127.077816 | 107.922262 | 86.975712 | 88.770895 | 71.807229 | 60.640085 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on double+10x10 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on double+10x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 3.801 | 4.448 | 5.62740 | 4.9490 | 6.7115 | 15.706 |
| 2 | rowMads | 3.791 | 4.528 | 5.80493 | 5.5455 | 6.9305 | 17.857 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.0000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads | 0.9973691 | 1.017986 | 1.031547 | 1.120529 | 1.032631 | 1.136954 |
Figure: Benchmarking of colMads() and rowMads() on double+10x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131789 167.3 5709258 305.0 5709258 305.0
Vcells 5760747 44.0 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131780 167.3 5709258 305.0 5709258 305.0
Vcells 5770785 44.1 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on double+100x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.349682 | 0.3518030 | 0.3636086 | 0.3545175 | 0.3583965 | 0.459405 |
| 2 | colMads2 | 0.366045 | 0.3685025 | 0.3782240 | 0.3729490 | 0.3786860 | 0.483824 |
| 3 | apply+mad | 5.317847 | 5.3774485 | 5.7515005 | 5.4465390 | 5.6497875 | 14.704099 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.046794 | 1.047468 | 1.040195 | 1.05199 | 1.056612 | 1.053154 |
| 3 | apply+mad | 15.207666 | 15.285397 | 15.817833 | 15.36324 | 15.764070 | 32.006833 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on double+100x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.349940 | 0.3518220 | 0.3597876 | 0.3541570 | 0.357123 | 0.459749 |
| 2 | rowMads2 | 0.363962 | 0.3667865 | 0.3841819 | 0.3709645 | 0.378762 | 0.497389 |
| 3 | apply+mad | 5.293078 | 5.3429990 | 5.6844816 | 5.4143890 | 5.605378 | 14.515281 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.00000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.04007 | 1.042534 | 1.067802 | 1.047458 | 1.060593 | 1.081871 |
| 3 | apply+mad | 15.12567 | 15.186654 | 15.799547 | 15.288104 | 15.695930 | 31.572186 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on double+100x100 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on double+100x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads | 349.940 | 351.822 | 359.7876 | 354.1570 | 357.1230 | 459.749 |
| 1 | colMads | 349.682 | 351.803 | 363.6086 | 354.5175 | 358.3965 | 459.405 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 2 | rowMads | 1.0000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 | 1.0000000 |
| 1 | colMads | 0.9992627 | 0.999946 | 1.01062 | 1.001018 | 1.003566 | 0.9992518 |
Figure: Benchmarking of colMads() and rowMads() on double+100x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x10"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132002 167.3 5709258 305.0 5709258 305.0
Vcells 5760891 44.0 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3131993 167.3 5709258 305.0 5709258 305.0
Vcells 5770929 44.1 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on double+1000x10 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.319538 | 0.320782 | 0.3246620 | 0.3223615 | 0.323855 | 0.399265 |
| 2 | colMads2 | 0.339217 | 0.342920 | 0.3488044 | 0.3464760 | 0.351911 | 0.399494 |
| 3 | apply+mad | 1.018295 | 1.040587 | 1.0570449 | 1.0493055 | 1.061317 | 1.229027 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.061586 | 1.069013 | 1.074362 | 1.074806 | 1.086631 | 1.000574 |
| 3 | apply+mad | 3.186773 | 3.243909 | 3.255832 | 3.255058 | 3.277136 | 3.078224 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on double+1000x10 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.321946 | 0.3238615 | 0.3290887 | 0.3253700 | 0.3276720 | 0.439519 |
| 2 | rowMads2 | 0.351109 | 0.3544465 | 0.3616638 | 0.3564045 | 0.3604995 | 0.558510 |
| 3 | apply+mad | 0.976665 | 0.9961980 | 1.0128853 | 1.0049680 | 1.0122460 | 1.624371 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.090583 | 1.094439 | 1.098986 | 1.095382 | 1.100184 | 1.270730 |
| 3 | apply+mad | 3.033630 | 3.076000 | 3.077849 | 3.088693 | 3.089205 | 3.695792 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on double+1000x10 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on double+1000x10 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 319.538 | 320.7820 | 324.6620 | 322.3615 | 323.855 | 399.265 |
| 2 | rowMads | 321.946 | 323.8615 | 329.0887 | 325.3700 | 327.672 | 439.519 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.0000 | 1.000000 | 1.000000 | 1.000000 | 1.00000 |
| 2 | rowMads | 1.007536 | 1.0096 | 1.013635 | 1.009333 | 1.011786 | 1.10082 |
Figure: Benchmarking of colMads() and rowMads() on double+1000x10 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["10x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132207 167.3 5709258 305.0 5709258 305.0
Vcells 5761966 44.0 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132198 167.3 5709258 305.0 5709258 305.0
Vcells 5772004 44.1 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on double+10x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 0.353791 | 0.357329 | 0.3684474 | 0.3635500 | 0.3742925 | 0.428783 |
| 2 | colMads2 | 0.394643 | 0.398898 | 0.4210527 | 0.4124335 | 0.4244375 | 0.944717 |
| 3 | apply+mad | 46.990760 | 47.771606 | 50.8558312 | 48.7180135 | 51.6360770 | 72.002669 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.115469 | 1.116333 | 1.142776 | 1.134462 | 1.133973 | 2.203252 |
| 3 | apply+mad | 132.820677 | 133.690817 | 138.027385 | 134.006364 | 137.956483 | 167.923329 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on double+10x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 0.353801 | 0.3583675 | 0.3719788 | 0.3648355 | 0.3774410 | 0.447620 |
| 2 | rowMads2 | 0.394059 | 0.3991600 | 0.4224268 | 0.4144305 | 0.4283835 | 0.600624 |
| 3 | apply+mad | 46.881594 | 47.9615465 | 51.2745530 | 49.4159515 | 54.1775520 | 68.100929 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.113787 | 1.113829 | 1.135621 | 1.135938 | 1.134968 | 1.341817 |
| 3 | apply+mad | 132.508371 | 133.833415 | 137.842668 | 135.447213 | 143.539128 | 152.140050 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on double+10x1000 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on double+10x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 353.791 | 357.3290 | 368.4474 | 363.5500 | 374.2925 | 428.783 |
| 2 | rowMads | 353.801 | 358.3675 | 371.9788 | 364.8355 | 377.4410 | 447.620 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads | 1.000028 | 1.002906 | 1.009585 | 1.003536 | 1.008412 | 1.043931 |
Figure: Benchmarking of colMads() and rowMads() on double+10x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["100x1000"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132420 167.3 5709258 305.0 5709258 305.0
Vcells 5762110 44.0 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132411 167.3 5709258 305.0 5709258 305.0
Vcells 5862148 44.8 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on double+100x1000 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 3.551345 | 3.561309 | 3.617673 | 3.580302 | 3.598743 | 4.499594 |
| 2 | colMads2 | 3.601147 | 3.615731 | 3.703038 | 3.634491 | 3.700569 | 4.684895 |
| 3 | apply+mad | 53.368024 | 54.302672 | 58.494918 | 56.169742 | 58.477301 | 79.849003 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.014023 | 1.015281 | 1.023596 | 1.015135 | 1.028295 | 1.041182 |
| 3 | apply+mad | 15.027553 | 15.247953 | 16.169209 | 15.688549 | 16.249371 | 17.745824 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on double+100x1000 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 3.562192 | 3.583538 | 3.687924 | 3.675622 | 3.722243 | 4.199921 |
| 2 | rowMads2 | 3.634564 | 3.670988 | 3.837768 | 3.750459 | 3.890684 | 4.883184 |
| 3 | apply+mad | 53.086682 | 53.913863 | 57.987541 | 55.042718 | 58.769833 | 70.578594 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.00000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.020317 | 1.024403 | 1.040631 | 1.02036 | 1.045252 | 1.162685 |
| 3 | apply+mad | 14.902813 | 15.044870 | 15.723626 | 14.97508 | 15.788820 | 16.804743 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on double+100x1000 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on double+100x1000 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 3.551345 | 3.561309 | 3.617673 | 3.580302 | 3.598743 | 4.499594 |
| 2 | rowMads | 3.562192 | 3.583538 | 3.687924 | 3.675622 | 3.722243 | 4.199921 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.0000 |
| 2 | rowMads | 1.003054 | 1.006242 | 1.019419 | 1.026623 | 1.034318 | 0.9334 |
Figure: Benchmarking of colMads() and rowMads() on double+100x1000 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

> X <- data[["1000x100"]]
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132632 167.4 5709258 305.0 5709258 305.0
Vcells 5763412 44.0 22267496 169.9 56666022 432.4
> colStats <- microbenchmark(colMads = colMads(X, na.rm = FALSE), colMads2 = colMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 2L, FUN = mad, na.rm = FALSE), unit = "ms")
> X <- t(X)
> gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 3132623 167.4 5709258 305.0 5709258 305.0
Vcells 5863450 44.8 22267496 169.9 56666022 432.4
> rowStats <- microbenchmark(rowMads = rowMads(X, na.rm = FALSE), rowMads2 = rowMads2(X, na.rm = FALSE),
+ `apply+mad` = apply(X, MARGIN = 1L, FUN = mad, na.rm = FALSE), unit = "ms")Table: Benchmarking of colMads(), colMads2() and apply+mad() on double+1000x100 data. The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 3.301402 | 3.336935 | 3.441625 | 3.369768 | 3.445602 | 4.353206 |
| 2 | colMads2 | 3.404427 | 3.462488 | 3.839495 | 3.513167 | 3.626749 | 15.573139 |
| 3 | apply+mad | 9.550131 | 9.723353 | 10.202366 | 9.851900 | 10.085211 | 19.316719 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | colMads2 | 1.031206 | 1.037625 | 1.115605 | 1.042554 | 1.052573 | 3.577395 |
| 3 | apply+mad | 2.892750 | 2.913858 | 2.964403 | 2.923614 | 2.926981 | 4.437355 |
Table: Benchmarking of rowMads(), rowMads2() and apply+mad() on double+1000x100 data (transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 3.330468 | 3.348110 | 3.425502 | 3.385632 | 3.442791 | 4.230056 |
| 2 | rowMads2 | 3.452394 | 3.482464 | 3.672875 | 3.536372 | 3.600909 | 10.834396 |
| 3 | apply+mad | 9.656374 | 9.694603 | 10.244143 | 9.776920 | 9.922432 | 19.092269 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | rowMads | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 | 1.000000 |
| 2 | rowMads2 | 1.036609 | 1.040129 | 1.072215 | 1.044523 | 1.045927 | 2.561289 |
| 3 | apply+mad | 2.899405 | 2.895545 | 2.990553 | 2.887769 | 2.882090 | 4.513479 |
Figure: Benchmarking of colMads(), colMads2() and apply+mad() on double+1000x100 data as well as rowMads(), rowMads2() and apply+mad() on the same data transposed. Outliers are displayed as crosses. Times are in milliseconds.

Table: Benchmarking of colMads() and rowMads() on double+1000x100 data (original and transposed). The top panel shows times in milliseconds and the bottom panel shows relative times.
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 3.301402 | 3.336935 | 3.441625 | 3.369768 | 3.445602 | 4.353206 |
| 2 | rowMads | 3.330468 | 3.348110 | 3.425502 | 3.385632 | 3.442791 | 4.230056 |
| expr | min | lq | mean | median | uq | max | |
|---|---|---|---|---|---|---|---|
| 1 | colMads | 1.000000 | 1.000000 | 1.0000000 | 1.000000 | 1.000000 | 1.0000000 |
| 2 | rowMads | 1.008804 | 1.003349 | 0.9953151 | 1.004708 | 0.999184 | 0.9717105 |
Figure: Benchmarking of colMads() and rowMads() on double+1000x100 data (original and transposed). Outliers are displayed as crosses. Times are in milliseconds.

R version 3.6.1 Patched (2019-08-27 r77078)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS
Matrix products: default
BLAS: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-3-6-branch/lib/R/lib/libRlapack.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] microbenchmark_1.4-6 matrixStats_0.55.0-9000 ggplot2_3.2.1
[4] knitr_1.24 R.devices_2.16.0 R.utils_2.9.0
[7] R.oo_1.22.0 R.methodsS3_1.7.1 history_0.0.0-9002
loaded via a namespace (and not attached):
[1] Biobase_2.45.0 bit64_0.9-7 splines_3.6.1
[4] network_1.15 assertthat_0.2.1 highr_0.8
[7] stats4_3.6.1 blob_1.2.0 robustbase_0.93-5
[10] pillar_1.4.2 RSQLite_2.1.2 backports_1.1.4
[13] lattice_0.20-38 glue_1.3.1 digest_0.6.20
[16] colorspace_1.4-1 sandwich_2.5-1 Matrix_1.2-17
[19] XML_3.98-1.20 lpSolve_5.6.13.3 pkgconfig_2.0.2
[22] genefilter_1.66.0 purrr_0.3.2 ergm_3.10.4
[25] xtable_1.8-4 mvtnorm_1.0-11 scales_1.0.0
[28] tibble_2.1.3 annotate_1.62.0 IRanges_2.18.2
[31] TH.data_1.0-10 withr_2.1.2 BiocGenerics_0.30.0
[34] lazyeval_0.2.2 mime_0.7 survival_2.44-1.1
[37] magrittr_1.5 crayon_1.3.4 statnet.common_4.3.0
[40] memoise_1.1.0 laeken_0.5.0 R.cache_0.13.0
[43] MASS_7.3-51.4 R.rsp_0.43.1 tools_3.6.1
[46] multcomp_1.4-10 S4Vectors_0.22.1 trust_0.1-7
[49] munsell_0.5.0 AnnotationDbi_1.46.1 compiler_3.6.1
[52] rlang_0.4.0 grid_3.6.1 RCurl_1.95-4.12
[55] cwhmisc_6.6 rappdirs_0.3.1 labeling_0.3
[58] bitops_1.0-6 base64enc_0.1-3 boot_1.3-23
[61] gtable_0.3.0 codetools_0.2-16 DBI_1.0.0
[64] markdown_1.1 R6_2.4.0 zoo_1.8-6
[67] dplyr_0.8.3 bit_1.1-14 zeallot_0.1.0
[70] parallel_3.6.1 Rcpp_1.0.2 vctrs_0.2.0
[73] DEoptimR_1.0-8 tidyselect_0.2.5 xfun_0.9
[76] coda_0.19-3 Total processing time was 1.32 mins.
To reproduce this report, do:
html <- matrixStats:::benchmark('colMads')Copyright Henrik Bengtsson. Last updated on 2019-09-10 20:43:11 (-0700 UTC). Powered by RSP.
<script> var link = document.createElement('link'); link.rel = 'icon'; link.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAA21BMVEUAAAAAAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8AAP8BAf4CAv0DA/wdHeIeHuEfH+AgIN8hId4lJdomJtknJ9g+PsE/P8BAQL9yco10dIt1dYp3d4h4eIeVlWqWlmmXl2iYmGeZmWabm2Tn5xjo6Bfp6Rb39wj4+Af//wA2M9hbAAAASXRSTlMAAQIJCgsMJSYnKD4/QGRlZmhpamtsbautrrCxuru8y8zN5ebn6Pn6+///////////////////////////////////////////LsUNcQAAAS9JREFUOI29k21XgkAQhVcFytdSMqMETU26UVqGmpaiFbL//xc1cAhhwVNf6n5i5z67M2dmYOyfJZUqlVLhkKucG7cgmUZTybDz6g0iDeq51PUr37Ds2cy2/C9NeES5puDjxuUk1xnToZsg8pfA3avHQ3lLIi7iWRrkv/OYtkScxBIMgDee0ALoyxHQBJ68JLCjOtQIMIANF7QG9G9fNnHvisCHBVMKgSJgiz7nE+AoBKrAPA3MgepvgR9TSCasrCKH0eB1wBGBFdCO+nAGjMVGPcQb5bd6mQRegN6+1axOs9nGfYcCtfi4NQosdtH7dB+txFIpXQqN1p9B/asRHToyS0jRgpV7nk4nwcq1BJ+x3Gl/v7S9Wmpp/aGquum7w3ZDyrADFYrl8vHBH+ev9AUASW1dmU4h4wAAAABJRU5ErkJggg==" document.getElementsByTagName('head')[0].appendChild(link); </script>