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

l2norm

Compute L2 distance between two vectors of numbers.


Description

Compute L2 distance between two vectors of numbers (square root of sum of squares of differences between two vectors).

Usage

l2norm(u,v)

Arguments

u

first vector of numbers

v

second vector of numbers

Details

Function simply computes the L2 distance between two vectors and is implemented as

sqrt(sum((u-v)^2))

Value

A real number which is the L2 distance between two vectors.

RELEASE

Version 3.6 Copyright Guy Nason 1995

Note

This function would probably be more accurate if it used the Splus function vecnorm.

Author(s)

G P Nason

See Also

Examples

#
# What is the L2 norm between the following sets of vectors
#
p <- c(1,2,3,4,5)
q <- c(1,2,3,4,5)
r <- c(2,3,4,5,6)
l2norm(p,q)
# [1] 0
l2norm(q,r)
# [1] 2.236068
l2norm(r,p)
# [1] 2.236068

wavethresh

Wavelets Statistics and Transforms

v4.6.8
GPL (>= 2)
Authors
Guy Nason [aut, cre]
Initial release
2016-10-18

We don't support your browser anymore

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