original_docstring:  Mutual information of x and y (conditioned on z if z is not None)
          x, y 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: Mutual information of x and y (conditioned on z if z is not None)
  x, y should be a list of vectors, e.g.
docstring_tokens: Mutual information of x and y ( conditioned on z if z is not None ) x y should be a list of vectors e . g .
code: def mi(x, y, z=None, k=3, base=2, alpha=0):
      """ Mutual information of x and y (conditioned on z if z is not None)
          x, y 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 len(x) == len(y), "Arrays should have same length"
      assert k <= len(x) - 1, "Set k smaller than num. samples - 1"
      x, y = np.asarray(x), np.asarray(y)
      x, y = x.reshape(x.shape[0], -1), y.reshape(y.shape[0], -1)
      x = add_noise(x)
      y = add_noise(y)
      points = [x, y]
      if z is not None:
          z = np.asarray(z)
          z = z.reshape(z.shape[0], -1)
          points.append(z)
      points = np.hstack(points)
      # Find nearest neighbors in joint space, p=inf means max-norm
      tree = build_tree(points)
      dvec = query_neighbors(tree, points, k)
      if z is None:
          a, b, c, d = avgdigamma(x, dvec), avgdigamma(
              y, dvec), digamma(k), digamma(len(x))
          if alpha > 0:
              d += lnc_correction(tree, points, k, alpha)
      else:
          xz = np.c_[x, z]
          yz = np.c_[y, z]
          a, b, c, d = avgdigamma(xz, dvec), avgdigamma(
              yz, dvec), avgdigamma(z, dvec), digamma(k)
      return (-a - b + c + d) / log(base)
code_tokens: def mi ( x , y , z = None , k = 3 , base = 2 , alpha = 0 ) : assert len ( x ) == len ( y ) , "Arrays should have same length" assert k <= len ( x ) - 1 , "Set k smaller than num. samples - 1" x , y = np . asarray ( x ) , np . asarray ( y ) x , y = x . reshape ( x . shape [ 0 ] , - 1 ) , y . reshape ( y . shape [ 0 ] , - 1 ) x = add_noise ( x ) y = add_noise ( y ) points = [ x , y ] if z is not None : z = np . asarray ( z ) z = z . reshape ( z . shape [ 0 ] , - 1 ) points . append ( z ) points = np . hstack ( points ) tree = build_tree ( points ) dvec = query_neighbors ( tree , points , k ) if z is None : a , b , c , d = avgdigamma ( x , dvec ) , avgdigamma ( y , dvec ) , digamma ( k ) , digamma ( len ( x ) ) if alpha > 0 : d += lnc_correction ( tree , points , k , alpha ) else : xz = np . c_ [ x , z ] yz = np . c_ [ y , z ] a , b , c , d = avgdigamma ( xz , dvec ) , avgdigamma ( yz , dvec ) , avgdigamma ( z , dvec ) , digamma ( k ) return ( - a - b + c + d ) / log ( base )
short_docstring: Mutual information of x and y (conditioned on z if z is not None)
  x, y should be a list of vectors, e.g.
short_docstring_tokens: Mutual information of x and y ( conditioned on z if z is not None ) x y should be a list of vectors e . g .
comment: """ Mutual information of x and y (conditioned on z if z is not None)
          x, y 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
      """$SEP$# Find nearest neighbors in joint space, p=inf means max-norm