original_docstring:  The classic K-L k-nearest neighbor continuous entropy estimator
          x should be a list of vectors, e.g. x = [[1.3], [3.7], [5.1], [2.4]]
          if x is a one-dimensional scalar and we have four samples
      
docstring: The classic K-L k-nearest neighbor continuous entropy estimator
  x should be a list of vectors, e.g.
docstring_tokens: The classic K - L k - nearest neighbor continuous entropy estimator x should be a list of vectors e . g .
code: def entropy(x, k=3, base=2):
      """ The classic K-L k-nearest neighbor continuous entropy estimator
          x should be a list of vectors, e.g. x = [[1.3], [3.7], [5.1], [2.4]]
          if x is a one-dimensional scalar and we have four samples
      """
      assert k <= len(x) - 1, "Set k smaller than num. samples - 1"
      x = np.asarray(x)
      n_elements, n_features = x.shape
      x = add_noise(x)
      tree = build_tree(x)
      nn = query_neighbors(tree, x, k)
      const = digamma(n_elements) - digamma(k) + n_features * log(2)
      return (const + n_features * np.log(nn).mean()) / log(base)
code_tokens: def entropy ( x , k = 3 , base = 2 ) : assert k <= len ( x ) - 1 , "Set k smaller than num. samples - 1" x = np . asarray ( x ) n_elements , n_features = x . shape x = add_noise ( x ) tree = build_tree ( x ) nn = query_neighbors ( tree , x , k ) const = digamma ( n_elements ) - digamma ( k ) + n_features * log ( 2 ) return ( const + n_features * np . log ( nn ) . mean ( ) ) / log ( base )
short_docstring: The classic K-L k-nearest neighbor continuous entropy estimator
  x should be a list of vectors, e.g.
short_docstring_tokens: The classic K - L k - nearest neighbor continuous entropy estimator x should be a list of vectors e . g .
comment: """ The classic K-L k-nearest neighbor continuous entropy estimator
          x should be a list of vectors, e.g. x = [[1.3], [3.7], [5.1], [2.4]]
          if x is a one-dimensional scalar and we have four samples
      """