MATLAB: Normalize to unit norm

unit norm

I have a variable containing a probability distribution (just an one-dimensional array of values). How can I normalize a to unit norm?

Best Answer

If you want to normalize a vector to have unit L2 norm.
x = randn(100,1);
x = x./norm(x,2);
norm(x,2)
Related Question