code: function findMedianRange(values) {
    var result = [null, null];
  
    if (values.length > 0) {
      var n = values.length;
  
      // Calculate mean value
      var mean = _.reduce(values, (memo, value) => {
        return memo + value / n;
      }, 0);
  
      // Calculate deviation
      var deviation = _.reduce(values, (memo, value) => {
        var d = Math.abs(value - mean);
        return memo + d / n;
      }, 0);
  
      result[0] = mean - deviation;
      result[1] = mean + deviation;
  
      // Calculate min and max values in array and clamp calculated range
      var min = _.min(values);
      var max = _.max(values);
  
      if (result[0] < min) {
        result[0] = min;
      }
      if (result[1] > max) {
        result[1] = max;
      }
    }
  
    result.min = result[0];
    result.max = result[1];
    return result;
  }
docs: This algorithm is used to find min and max value for coloring range. Values array may contain several values that are 100 or more times larger then other values. In this case, we'll have few fully colored regions on map, and other ones will be desaturated (because all of them has 100 times less values, comparing to max). So this function calculates mean value (m) and deviation (d) for values array. Calculated range is (m - d; m + d) and it is includes most values in array.