R/compute_kernel_Gaussian.R

Defines functions euclid_distance kernel_Gaussian compute_kernel_Gaussian

compute_kernel_Gaussian <- function(x, centers, sigma) {
  apply(centers, 1, function(center) {
    apply(x, 1, function(row) {
      kernel_Gaussian(row, center, sigma)
    })
  })
}

kernel_Gaussian <- function(x, y, sigma) {
  exp(- euclid_distance(x, y) / (2 * sigma * sigma))
}

euclid_distance <- function(x, y) {
  sqrt(sum((x - y) ^ 2))
}

Try the densratio package in your browser

Any scripts or data that you put into this service are public.

densratio documentation built on May 29, 2017, 11 a.m.