Normalize to unit norm

6 visualizaciones (últimos 30 días)
Nuchto
Nuchto el 27 de Mayo de 2012
I have a variable containing a probability distribution (just an one-dimensional array of values). How can I normalize a to unit norm?

Respuesta aceptada

Wayne King
Wayne King el 27 de Mayo de 2012
If you want to normalize a vector to have unit L2 norm.
x = randn(100,1);
x = x./norm(x,2);
norm(x,2)
  12 comentarios
Nuchto
Nuchto el 2 de Jun. de 2012
Thanks, it works now. What is in lay terms :) the difference between l1 and l2 norm?
Oleg Komarov
Oleg Komarov el 2 de Jun. de 2012
http://en.wikipedia.org/wiki/Norm_%28mathematics%29, Euclidean vs taxicab

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by