I'm having some difficulties with R right now.
What I have:
- a vector with minimal values for each triangular kernel
- a vector with maximal values
- a vector with the "middle" point (where the pick of each triangular should be)
What I need:
- a density estimate (triangular kernels ofc)开发者_Go百科
See if you can build on this example of varying bandwidth specifications to the base density function with a triagular kernel:
data("faithful", package = "datasets")
x <- faithful$waiting
opar <- par(mfcol= c(2,2))
for (bw in c(3,6,12,18) ) {
hist(x, xlab = "Waiting interval", ylab = "Eruption Freq",
probability = TRUE, main = "Density plot: Triangular kernel",
border = "gray", sub= bquote("Bandwidth = "*.(bw) ) )
lines(density(x, width = bw, window = "triangular"), lty=3, col="red")
}
par(opar)
精彩评论