code: function scale(input, options = {}) {
                  const {
                      min,
                      max
                  } = options;
  
                  var y = options.inPlace ? input : (new Array(input.length));
                  var minMax = Stat.minMax(input);
  
                  if (typeof max === 'number') {
                      if (typeof min === 'number') {
                          let factor = (max - min) / (minMax.max - minMax.min);
                          for (let i = 0; i < y.length; i++) {
                              y[i] = (input[i] - minMax.min) * factor + min;
                          }
                      } else if (minMax.max !== 0) {
                          let factor = max / minMax.max;
                          for (let i = 0; i < y.length; i++) {
                              y[i] = input[i] * factor;
                          }
                      } else {
                          options.min = minMax.min;
                          y = scale(input, options);
                      }
                  } else if (typeof min === 'number') {
                      if (minMax.min !== 0) {
                          let factor = min / minMax.min;
                          for (let i = 0; i < y.length; i++) {
                              y[i] = input[i] * factor;
                          }
  
                      } else {
                          options.max = minMax.max;
                          y = scale(input, options);
                      }
                  }
                  return y;
              }
docs: To scale the input array between the specified min and max values. The operation is performed inplace
  if the options.inplace is specified. If only one of the min or max parameters is specified, then the scaling
  will multiply the input array by min/min(input) or max/max(input)
  @param input
  @param options
  @returns {*}