-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Rename function to compute epanechnikov
- Loading branch information
Showing
5 changed files
with
32 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
R/calculate-weights-epanechnikov.R → R/compute-epanechnikov.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
#' Epanechnikov kernel | ||
#' Compute the Epanechnikov function | ||
#' | ||
#' The kernel is one of the quadratic kernels used | ||
#' in kernel density estimation. | ||
#' | ||
#' Epanechnikov kernel is defined as follows: | ||
#' The Epanechnikov function is one of the quadratic kernels used in | ||
#' kernel density estimation. It is defined as follows: | ||
#' \deqn{K(x) = \frac{3}{4}(1 - x^2) \quad \text{if} \quad |x| \leq 1\text{.}} | ||
#' | ||
#' @param x A numeric vector. | ||
#' @return A numeric vector of weights of the kernel for each input points. | ||
#' @export | ||
#' @examples | ||
#' x <- seq(-3, 3, 0.1) | ||
#' y <- calculate_weights_epanechnikov(x) | ||
#' plot(x, y, type = "l") | ||
calculate_weights_epanechnikov <- function(x) { | ||
#' y <- compute_epanechnikov(x) | ||
#' plot(x, y, xlim = c(-3, 3), ylim = c(0, 1), type = "l") | ||
compute_epanechnikov <- function(x) { | ||
return(ifelse(abs(x) <= 1, (3 / 4) * (1 - x^2), 0)) | ||
} |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters