/usr/lib/R/site-library/matrixStats/benchmarking/binMeans.md.rsp is in r-cran-matrixstats 0.14.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | <%@include file="includes/setup.md.rsp"%>
<%@string fcnname="binMeans"%>
<% fcnname <- "<%@string name="fcnname"%>" %>
<%@meta title="${fcnname}() benchmarks"%>
<%@meta author="Henrik Bengtsson"%>
<%@meta date="2014-06-04"%>
<%@include file="${header}"%>
# <%@meta name="title"%>
This report benchmark the performance of <%=fcnname%>() against alternative methods.
## Alternative methods
* binMeans_R()
which is defined as
```r
<%=withCapture({
binMeans_R <- function(y, x, bx, na.rm=FALSE, count=TRUE, right=FALSE) {
B <- length(bx)-1L
res <- double(B)
counts <- integer(B)
# For each bin...
for (kk in seq(length=B)) {
if (right) {
idxs <- which(bx[kk] < x & x <= bx[kk+1L])
} else {
idxs <- which(bx[kk] <= x & x < bx[kk+1L])
}
yKK <- y[idxs]
muKK <- mean(yKK)
res[kk] <- muKK
counts[kk] <- length(idxs)
} # for (kk ...)
if (count) attr(res, "count") <- counts
res
} # binMeans_R()
})%>
```
## Results
### Non-sorted simulated data
```r
<%=withCapture({
nx <- 10e3 # Number of data points
set.seed(0xBEEF)
x <- runif(nx, min=0, max=1)
y <- runif(nx, min=0, max=1)
# Uniformely distributed bins
nb <- 1e3 # Number of bins
bx <- seq(from=0, to=1, length.out=nb+1L)
bx <- c(-1, bx, 2)
})%>
```
<% benchmark <- function() { %>
<% dataLabel <- if (is.unsorted(x)) "unsorted" else "sorted" %>
<% message(dataLabel) %>
```r
<%=withCapture({
gc()
stats <- microbenchmark(
binMeans = binMeans(x=x, y=y, bx=bx, count=TRUE),
binMeans_R = binMeans_R(x=x, y=y, bx=bx, count=TRUE),
unit = "ms"
)
})%>
```
<% benchmarkResults(stats, tags=dataLabel) %>
<% } # benchmark() %>
<% benchmark() %>
### Sorted simulated data
```r
<%=withCapture({
x <- sort(x)
})%>
```
<% benchmark() %>
<%@include file="${footer}"%>
<%---------------------------------------------------------------------------
HISTORY:
2014-06-02
o Restructured.
2014-05-25
o Created.
---------------------------------------------------------------------------%>
|