# 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)
Run the code above in your browser using DataLab