How can I normalize a data between 0-1 without having its maximum value?

Hello to all
I want to write the following formula code (population density) in MATLAB for an optimization algorithm. As a rule, this parameter is different in each generation depending on the new population.
I have two questions:
1) Is the code I wrote correct? I don't know why the numbers obtained from this formula are very close to each other in each generation.
2) How can I normalize this parameter in each generation? Its maximum value is not determined until all generations are executed.
the code is:
summ11=0;
summ1=0;
for i=1:numel(pop)-1
for j=i+1:numel(pop)
y=pop(i).position-pop(j).position;
D=numel(y);
for jj=1:D
summ1= summ1+(y(jj)^2/(varmax(jj)-varmin(jj)));
end
summ11=sqrt(summ1);
end
summ11=summ1+summ11;
end
div1= summ11;
div123=div1/((2*D*(numel(pop)-1)*numel(pop)));

H and L are upper bound and lower bound of design variables respectively.
d is the number of design variables and n is population size.

7 Comments

If you have no idea what the min and max are, then you cannot possibly normalize your data to lie between any limits, until you know what the limits of your data are. At least this is the case if your normalization is a linear transformation.
What if I know the minimum?
Can something be done in this case?
summ11=0;
summ1=0;
for i=1:numel(pop)-1
for j=i+1:numel(pop)
y=pop(i).position-pop(j).position;
D=numel(y);
for jj=1:D
summ1= summ1+(y(jj)^2/(varmax(jj)-varmin(jj)));
end
summ11=sqrt(summ1);
end
summ11=summ1+summ11;
end
Unrecognized function or variable 'pop'.
div1= summ11;
div123=div1/((2*D*(numel(pop)-1)*numel(pop)));
What is pop?
pop is a random population.
you can use: pop=rand(100,30)
I didn't copy all my program code here.
Anyway, did you see my answer below? Scroll down.
yes I saw but I don't have a vector or sth like it, I only have a scalar per generation which is calculated by the formula above.
A single scalar cannot be normalized without a max or min value to set the normalization limits. You've said you don't know the max or min, and presumably that means they're not obtainable or computable by any means. So all you can do is to assign that scalar to some value like 0 or 1 or whatever value you want. Why do you think you want to normalize a value for which the max is unobtainable? And WHY is the max not obtainable?

Sign in to comment.

Answers (1)

If you have an array, you can normalize it with normalize or rescale
data = rand(1, 3)
data = 1×3
0.4520 0.7409 0.2085
normalizedData = rescale(data, 0, 1)
normalizedData = 1×3
0.4573 1.0000 0

Categories

Products

Release

R2021b

Asked:

on 14 Nov 2022

Commented:

on 19 Nov 2022

Community Treasure Hunt

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

Start Hunting!