MATLAB Answers

How to normalize well data between [-1,1]?

35 views (last 30 days)
SL
SL on 23 Oct 2016
Answered: Image Analyst on 23 Oct 2016
Proposal which gives a results which looks correct; Can you return the original vector from the normalised result?
% https://se.mathworks.com/matlabcentral/answers/154075-how-to-scale-normalize-values-in-a-matrix-to-be-between-1-and-1
a = -1 + 2.*(a - min(a))./(max(a) - min(a));
Other proposed normalizations but they do not work, giving wrong range
a = normalize(a);
a = a/norm(a);
I am processing MIT-BIH arrythmia database signals.
MATLAB: 2016b OS: Debian 8.5

  0 Comments

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 23 Oct 2016
Edited: John D'Errico on 23 Oct 2016
Well, think about it! Without knowledge of the scaling and translation done, how could you possibly regenerate the original data? If you discard information content, that information is lost.
Were you to save that information, (i.e., the min and max of your data) then it is trivial to reverse the normalization.
And of course the two alternatives you list don't work, since both a translation and scaling are needed to achieve the final range you desire.

  2 Comments

SL
SL on 23 Oct 2016
After translation and scaling, how can you evaluate those three normalization methods? - - Can you say if anyone is the best?
John D'Errico
John D'Errico on 23 Oct 2016
Um, you seem to think that mathematics is a matter of debate. Should we vote on whether 1+1=2? Or perhaps we can vote on 1+2-2+1=2, and if this is a better method. I hope not. Well, maybe we can vote on the value of pi. That was even a matter of debate at one time, between a set of people who had no clue about mathematics.
Talking about these various "methods" as if that is the case is silly. Instead, look at mathematics. Mathematics is simple, and there is no debate.
Consider the vector
a = [1 2];
I don't have access to the normalize function, so I cannot compare what it does. Anyway, there are many functions out there called normalize.m. I found at least a few on the file exchange, or maybe there is a toolbox function called normalize. I can't know which one you found. If you want to understand the code there, just read the code you found, or test it out. Does it do what you asked for?
What does dividing that vector by the norm do? Will the min be -1 after the transformation? Will the maximum be +1? Does it do what you wanted? NO. Then why are you even asking this question?
You say "after translation and scaling". What do you mean by that? Only one of the expressions you show involves a translation. Perhaps you want to modify those alternatives so they involve a translation. If so, then you need to tell me what transformation you want to look at.
Theorem: Any LINEAR transformation that maps a fixed vector (a) such that
min(a) --> -1
max(a) --> +1
is unique. Yes, you can write it in various ways. But that is not relevant. If the mapping is such as I describe above, it is unique. Note that I said the transformation must be linear for this to hold true. But all of the transformations you have described are linear re-mappings of the real line.
So, given the above simple theorem, if the first expression you show has the properties:
1. It is a linear transformation of a fixed vector a
2. It maps min(a) to -1
3. it maps max(a) to +1
then it does what you want, and it is unique. Feel free to test the other transformations you showed. Do they do what you want? If not, then why are you asking which is better than the others? "Better" is a subjective word, and totally unnecessary.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 23 Oct 2016
Simply save your original array if you need it later.
If you need it in other functions and it's out of scope, see THE FAQ to learn how to get it IN scope in the functions you need it.

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by