L1norm | R Documentation |
Intended to compute the L1norm of the difference between two distribution functions.
L1norm(F, G, eps = 1e-06)
F |
A stepfunction |
G |
Another stepfunction |
eps |
A tolerance parameter |
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
.
A real number.
R. Koenker
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.