#' Soft-thresholding function
#'
#' @param a scalar to be thresholded at level \code{lambda}
#' @param lambda threshold value, should be non-negative
#'
#' @return soft-thresholded value of a
#' @export
#'
#' @examples
#' soft(3, 1)
soft = function(a, lambda){
sign(a) * max(abs(a) - lambda, 0)
}
#' Hard-thresholding function
#'
#' @param a scalar to be thresholded at level \code{lambda}
#' @param lambda threshold value, should be non-negative
#'
#' @return hard-thresholded value of a
#' @export
#'
#' @examples
#'
hard = function(a, lambda){
if (abs(a) > lambda){
a
} else{
0
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.