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

22 Ansichten (letzte 30 Tage)

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 Kommentare
Zahra Mehraban
Zahra Mehraban am 19 Nov. 2022
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.
Image Analyst
Image Analyst am 19 Nov. 2022
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 15 Nov. 2022
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

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by