<%@include file="includes/setup.md.rsp"%> <%@string colname="colWeightedMedians"%> <%@string rowname="rowWeightedMedians"%> <%@meta title="${colname}() and ${rowname}() benchmarks"%> <%@meta author="Henrik Bengtsson"%> <%@meta date="2014-06-09"%> <%@include file="${header}"%> # <%@meta name="title"%> This report benchmark the performance of <%=colname%>() and <%=rowname%>() against alternative methods. ## Alternative methods * apply() + weightedMedian() ## Data ```r <%=withCapture({ <%@include file="R/random-matrices.R"%> data <- rmatrices(mode = "double") })%> ``` ## Results <% for (dataLabel in names(data)) { %> <% message(dataLabel) %> ### <%=dataLabel%> matrix ```r <%=withCapture({ X <- data[[.dataLabel.]] w <- runif(nrow(X)) gc() colStats <- microbenchmark( colWeightedMedians = colWeightedMedians(X, w = w, na.rm = FALSE), "apply+weigthedMedian" = apply(X, MARGIN = 2L, FUN = weightedMedian, w = w, na.rm = FALSE), unit = "ms" ) X <- t(X) gc() rowStats <- microbenchmark( rowWeightedMedians = rowWeightedMedians(X, w = w, na.rm = FALSE), "apply+weigthedMedian" = apply(X, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = FALSE), unit = "ms" ) })%> ``` <% crBenchmarkResults(colStats, rowStats, tags=dataLabel) %> <% } # for (dataLabel ...) %> <%@include file="${footer}"%> <%--------------------------------------------------------------------------- HISTORY: 2014-06-09 o Created. ---------------------------------------------------------------------------%>