Description Usage Arguments Examples
This is an internal function. The user may not use it.
1 | getEdges(z)
|
z |
a grid a scalar, usually created by
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | set.seed(123)
dat1 <- stats::rnorm(1e2)
h <- bw.nrd0(dat1)
z0 <- min(dat1) - 3*h
z1 <- max(dat1) + 3*h
ngrid <- 2^10
dt <- (z1 - z0) / (ngrid - 1)
z <- z0 + (0:(ngrid-1)) * dt
## Same as using seq function
## seq(z0, z1, length.out=ngrid)
binedge1 <- c(z - 0.5*dt, z[ngrid] + 0.5*dt)
binedge2 <- as.vector(cpda::getEdges(z))
all.equal(binedge1, binedge2)
mean(binedge - as.vector(tmp))
## [1] 2.640334e-17
## 4.00 vs. 14.1 microseconds
## library(microbenchmark)
## res <- microbenchmark(
## binedge1 <- c(z - 0.5*dt, z[ngrid] + 0.5*dt),
## binedge2 <- as.vector(cpda::getEdges(z)),
## times=10L)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.