Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

L1norm

L1norm for piecewise linear functions


Description

Intended to compute the L1norm of the difference between two distribution functions.

Usage

L1norm(F, G, eps = 1e-06)

Arguments

F

A stepfunction

G

Another stepfunction

eps

A tolerance parameter

Details

Both F and G should be of class stepfun, and they should be non-defective distribution functions. There are some tolerance issues in checking whether both functions are proper distribution functions at the extremes of their support. For simulations it may be prudent to wrap L1norm in try.

Value

A real number.

Author(s)

R. Koenker

Examples

# Make a random step (distribution) function with Gaussian knots
rstep <- function(n){
        x <- sort(rnorm(n))
        y <- runif(n)
        y <- c(0,cumsum(y/sum(y)))
        stepfun(x,y)
        }
F <- rstep(20)
G <- rstep(10)
S <- L1norm(F,G)
plot(F,main = paste("||F - G|| = ", round(S,4)))
lines(G,col = 2)

REBayes

Empirical Bayes Estimation and Inference

v2.2
GPL (>= 2)
Authors
Roger Koenker [aut, cre], Jiaying Gu [ctb], Ivan Mizera [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.