norm()

Read(279) Label: matrix, vector, normalize,

Description:

Normalize a matrix or a vector.

Syntax:

norm(A)

Note:

The function normalizes a matrix or a vector by subtracting the mean from each element of every row and then dividing each element by the square root of the sum of squares.

Parameters:

A

A matrix or a vector

Options:

@0

Enable subtracting the mean from each row only without keeping lengths same; the mean value after normalization is 0. The parameter is invalid when parameter A is a matrix

@s

0-1 normalization; mean value after normalization is 0, and standard deviation is 1

Return value:

A sequence

Example:

 

A

 

1

=[2,3,5]

 

2

=norm(A1)

Normalize a vector

3

=norm@0(A1)

Subtract the mean from each row only and mean value after normalization is 0

4

=norm@s(A1)

0-1 normalization

5

[[8, 1, 6], [3, 5, 7], [4, 9, 2]]

 

6

=norm(A5)


Normalize a matrix