Skip to main content
added 5 characters in body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536

Examples of KDE estimates with h=0.5, h=1, h=1.5, h=2Examples of KDE estimates with h=0.5, h=1, h=1.5, h=2

set.seed(123) n <- 7 x <- rnorm(n, sd = 3) K <- function(x) ifelse(x >= -1 & x <= 1, 1 - abs(x), 0) kde <- function(x, data, h, K) { n <- length(data) out <- outer(x, data, function(xi,yi) K((xi-yi)/h)) rowSums(out)/(n*h) } xx = seq(-8, 8, by = 0.001) for (h in c(0.5, 1, 1.5, 2)) { plot(NA, xlim = c(-4, 8), ylim = c(0, 0.5), xlab = "", ylab = "", main = paste0("h = ", h)) for (i in 1:n) { lines(xx, K((xx-x[i])/h)/n(n*h), type = "l", col = rainbow(n)[i]) rug(x[i], lwd = 2, col = rainbow(n)[i], side = 3, ticksize = 0.075) } lines(xx, kde(xx, x, h, K), col = "darkgray") } 

Examples of KDE estimates with h=0.5, h=1, h=1.5, h=2

set.seed(123) n <- 7 x <- rnorm(n, sd = 3) K <- function(x) ifelse(x >= -1 & x <= 1, 1 - abs(x), 0) kde <- function(x, data, h, K) { n <- length(data) out <- outer(x, data, function(xi,yi) K((xi-yi)/h)) rowSums(out)/(n*h) } xx = seq(-8, 8, by = 0.001) for (h in c(0.5, 1, 1.5, 2)) { plot(NA, xlim = c(-4, 8), ylim = c(0, 0.5), xlab = "", ylab = "", main = paste0("h = ", h)) for (i in 1:n) { lines(xx, K((xx-x[i])/h)/n, type = "l", col = rainbow(n)[i]) rug(x[i], lwd = 2, col = rainbow(n)[i], side = 3, ticksize = 0.075) } lines(xx, kde(xx, x, h, K), col = "darkgray") } 

Examples of KDE estimates with h=0.5, h=1, h=1.5, h=2

set.seed(123) n <- 7 x <- rnorm(n, sd = 3) K <- function(x) ifelse(x >= -1 & x <= 1, 1 - abs(x), 0) kde <- function(x, data, h, K) { n <- length(data) out <- outer(x, data, function(xi,yi) K((xi-yi)/h)) rowSums(out)/(n*h) } xx = seq(-8, 8, by = 0.001) for (h in c(0.5, 1, 1.5, 2)) { plot(NA, xlim = c(-4, 8), ylim = c(0, 0.5), xlab = "", ylab = "", main = paste0("h = ", h)) for (i in 1:n) { lines(xx, K((xx-x[i])/h)/(n*h), type = "l", col = rainbow(n)[i]) rug(x[i], lwd = 2, col = rainbow(n)[i], side = 3, ticksize = 0.075) } lines(xx, kde(xx, x, h, K), col = "darkgray") } 
added 25 characters in body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536

enter image description hereExamples of KDE estimates with h=0.5, h=1, h=1.5, h=2

enter image description here

Examples of KDE estimates with h=0.5, h=1, h=1.5, h=2

added 121 characters in body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536

$$ K(x) = \begin{cases} 1 - |x| & \text{if } x \in [0, 1] \\ 0 & \text{otherwise} \end{cases} $$$$ K(x) = \begin{cases} 1 - |x| & \text{if } x \in [-1, 1] \\ 0 & \text{otherwise} \end{cases} $$

This is illustrated on the plot below, where $n=7$ points are used for estimating kernel densities with different bandwidthes $h$ (colored points on top mark the individual values, colored lines are the kernels, gray line is overall kernel estimate). As you can see, $h < 1$ makes the kernels narrower, while $h > 1$ makes them wider. Changing $h$ influences both the individual kernels and the final kernel density estimate, since it's a mixture distribution of individual kernels. Higher $h$ makes the kernel density estimate smoother, while as $h$ gets smaller it leads to kernels being closer to individual datapoints, and with $h \rightarrow 0$ you would end up with just a bunch of Direc delta functions centered at $x_i$ points.

$$ K(x) = \begin{cases} 1 - |x| & \text{if } x \in [0, 1] \\ 0 & \text{otherwise} \end{cases} $$

This is illustrated on the plot below, where $n=7$ points are used for estimating kernel densities with different bandwidthes $h$ (colored points on top mark the individual values, colored lines are the kernels, gray line is overall kernel estimate). As you can see, $h < 1$ makes the kernels narrower, while $h > 1$ makes them wider. Changing $h$ influences both the individual kernels and the final kernel density estimate. Higher $h$ makes the kernel density estimate smoother, while as $h$ gets smaller it leads to kernels being closer to individual datapoints, and with $h \rightarrow 0$ you would end up with just a bunch of Direc delta functions centered at $x_i$ points.

$$ K(x) = \begin{cases} 1 - |x| & \text{if } x \in [-1, 1] \\ 0 & \text{otherwise} \end{cases} $$

This is illustrated on the plot below, where $n=7$ points are used for estimating kernel densities with different bandwidthes $h$ (colored points on top mark the individual values, colored lines are the kernels, gray line is overall kernel estimate). As you can see, $h < 1$ makes the kernels narrower, while $h > 1$ makes them wider. Changing $h$ influences both the individual kernels and the final kernel density estimate, since it's a mixture distribution of individual kernels. Higher $h$ makes the kernel density estimate smoother, while as $h$ gets smaller it leads to kernels being closer to individual datapoints, and with $h \rightarrow 0$ you would end up with just a bunch of Direc delta functions centered at $x_i$ points.

added 790 characters in body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536
Loading
added 790 characters in body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536
Loading
edited body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536
Loading
edited body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536
Loading
edited body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536
Loading
deleted 14 characters in body
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536
Loading
Source Link
Tim
  • 144k
  • 27
  • 277
  • 536
Loading