<%@include file="includes/setup.md.rsp"%>

<%@string colname="colWeightedMeans"%>
<%@string rowname="rowWeightedMeans"%>
<%@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() + weighted.mean()


## 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(
 colWeightedMeans     = colWeightedMeans(X, w = w, na.rm = FALSE),
"apply+weigthed.mean" = apply(X, MARGIN = 2L, FUN = weighted.mean, w = w, na.rm = FALSE),
 unit = "ms"
)

X <- t(X)
gc()

rowStats <- microbenchmark(
 rowWeightedMeans     = rowWeightedMeans(X, w = w, na.rm = FALSE),
"apply+weigthed.mean" = apply(X, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = FALSE),
 unit = "ms"
)
})%>
```

<% crBenchmarkResults(colStats, rowStats, tags=dataLabel) %>

<% } # for (dataLabel ...) %>


<%@include file="${footer}"%>


<%---------------------------------------------------------------------------
HISTORY:
2014-06-09
o Created.
---------------------------------------------------------------------------%>
