def similarity(palette)
      r, a, b = [], [], []
      (0..1).each { |i| a[i], b[i] = {}, {} }

      # r[i] is a hash of the multiple regression of the Palette in RGB space
      r[0] = fit
      r[1] = palette.fit

      [0, 1].each do |i|
        [:x, :y, :z].each do |k|
          a[i][k] = 0 * r[i][:slope][k] + r[i][:offset][k]
          b[i][k] = 255 * r[i][:slope][k] + r[i][:offset][k]
        end
      end

      d_max = sqrt(3 * (65025 ** 2))

      d1 = distance(a[0], a[1]) / d_max
      d2 = distance(b[0], b[1]) / d_max

      d1 + d2
    end
def similarity(palette)
      r, a, b = [], [], []
      (0..1).each { |i| a[i], b[i] = {}, {} }

      # r[i] is a hash of the multiple regression of the Palette in RGB space
      r[0] = fit
      r[1] = palette.fit

      [0, 1].each do |i|
        [:x, :y, :z].each do |k|
          a[i][k] = 0 * r[i][:slope][k] + r[i][:offset][k]
          b[i][k] = 255 * r[i][:slope][k] + r[i][:offset][k]
        end
      end

      d_max = sqrt(3 * (65025 ** 2))

      d1 = distance(a[0], a[1]) / d_max
      d2 = distance(b[0], b[1]) / d_max

      d1 + d2
    end
Calculate the similarity between the receiver and another {Palette}
 @param [Palette] palette palette to calculate the similarity to
 @return [Number] a value in [0..1] with 0 being identical and 1 being as dissimilar as possible