Open lpatiny opened 8 years ago
i zlthink it should be scale(array, options). Min and max can have default values
min:0, max:1 ?
No default values. If only min is defined the array will be multiplied simply by min/Stat.min(input) and if only max is specified then max/Stat.max(input). If both are specified then:
var minMax = Stat.minMax(input);
var factor = (max - min)/(minMax.max-minMax.min);
for(var i=0;i< y.length;i++){
y[i]=(input[i]-minMax.min)*factor+min;
}
The method also receive the inplace option, by default false
Don't know which behaviour is the more logical. I was expecting: You specify nothing : min = Stat.min, max=Stat.max -> we do nothing You specify min : min = newMin, max=Stat.max You specify max : min = Stat.min, max=newMax You specify min and max : min = newMin, max=newMax But I don't know what is the "usual" behaviour in some other software
about the option, should we use camelCase ?
=> inPlace
instead of inplace
inPlace change was made. About the other problem, I would prefer that if you don't specify min or max the 0 be maintained. So, it is about what you prefer to keep, your baseline or your unspecified value.
OK I guess both are useful ... What about other programs ? They allow both ? what could be the option name ?
could be inplace or as a new array
I think we should not throw an error