    # File lib/standard/facets/math/theil_index.rb, line 14
      def self.theil_index(array)
        return -1 if array.size <= 0 or any? { |x| x < 0 }
        return  0 if array.size <  2 or all? { |x| approx_equal(x, 0) }
        m = mean(array)
        s = sum(array).to_f
        inject(0) do |theil, xi|
                theil + ((xi > 0) ? (log(xi.to_f/m) * xi.to_f/s) : 0.0)
        end
      end