Problem:
----------
Very often, I have to do this sort of Normalization of data where the data should reside between say 0 and 1.
How to?
----------
Let's answer that by an example where I have to normalize the following vector.
(vector is a matrix with one column or one row! Sometime people call it row vector or column vector :D )
>> myvector=[ 5 7 20 9 10 5]
myvector =
5 7 20 9 10 5
So to normalize we have to divide each value by the sum of the vector.
normalized_myvector=myvector/sum(myvector)
normalized_myvector =
0.0893 0.1250 0.3571 0.1607 0.1786 0.0893
The normalized vector will always sum up to 1. To check that
>> sum(normalized_myvector)
ans =
1
----------
Very often, I have to do this sort of Normalization of data where the data should reside between say 0 and 1.
How to?
----------
Let's answer that by an example where I have to normalize the following vector.
(vector is a matrix with one column or one row! Sometime people call it row vector or column vector :D )
>> myvector=[ 5 7 20 9 10 5]
myvector =
5 7 20 9 10 5
So to normalize we have to divide each value by the sum of the vector.
normalized_myvector=myvector/sum(myvector)
normalized_myvector =
0.0893 0.1250 0.3571 0.1607 0.1786 0.0893
The normalized vector will always sum up to 1. To check that
>> sum(normalized_myvector)
ans =
1
No comments:
Post a Comment
Please ask if anything is not clear enough..........