code: def correlation(u, v, w=None, centered=True):
      """
      Compute the correlation distance between two 1-D arrays.
  
      The correlation distance between `u` and `v`, is
      defined as
  
      .. math::
  
          1 - \\frac{(u - \\bar{u}) \\cdot (v - \\bar{v})}
                    {{||(u - \\bar{u})||}_2 {||(v - \\bar{v})||}_2}
  
      where :math:`\\bar{u}` is the mean of the elements of `u`
      and :math:`x \\cdot y` is the dot product of :math:`x` and :math:`y`.
  
      Parameters
      ----------
      u : (N,) array_like
          Input array.
      v : (N,) array_like
          Input array.
      w : (N,) array_like, optional
          The weights for each value in `u` and `v`. Default is None,
          which gives each value a weight of 1.0
  
      Returns
      -------
      correlation : double
          The correlation distance between 1-D array `u` and `v`.
  
      """
      u = _validate_vector(u)
      v = _validate_vector(v)
      if w is not None:
          w = _validate_weights(w)
      if centered:
          umu = np.average(u, weights=w)
          vmu = np.average(v, weights=w)
          u = u - umu
          v = v - vmu
      uv = np.average(u * v, weights=w)
      uu = np.average(np.square(u), weights=w)
      vv = np.average(np.square(v), weights=w)
      dist = 1.0 - uv / np.sqrt(uu * vv)
      return dist
  
imports: from __future__ import division, print_function, absolute_import
  import warnings
  import numpy
  from functools import partial
  from collections import namedtuple
  from scipy._lib.six import callable, string_types
  from scipy._lib.six import xrange
  from scipy._lib._util import _asarray_validated
  from .None import _distance_wrap
  from .None import _hausdorff
  from ..linalg import norm
  from ..special import rel_entr
label_desc: Use image node_id 22 for calling a global function with example usage: correlation(u, v, w, centered) and returns: dist