docs: def cosine(h1, h2): # 17 us @array, 42 us @list \w 100 bins
      r"""
      Cosine simmilarity.
      
      Compute the angle between the two histograms in vector space irrespective of their
      length. The cosine similarity between two histograms :math:`H` and :math:`H'` of size
      :math:`m` is defined as:
      
      .. math::
      
          d_{\cos}(H, H') = \cos\alpha = \frac{H * H'}{\|H\| \|H'\|} = \frac{\sum_{m=1}^M H_m*H'_m}{\sqrt{\sum_{m=1}^M H_m^2} * \sqrt{\sum_{m=1}^M {H'}_m^2}}
      
      
      *Attributes:*
  
      - not a metric, a similarity
      
      *Attributes for normalized histograms:*
  
      - :math:`d(H, H')\in[0, 1]`
      - :math:`d(H, H) = 1`
      - :math:`d(H, H') = d(H', H)`
      
      *Attributes for not-normalized histograms:*
  
      - :math:`d(H, H')\in[-1, 1]`
      - :math:`d(H, H) = 1`
      - :math:`d(H, H') = d(H', H)`
      
      *Attributes for not-equal histograms:*
  
      - not applicable    
          
      Parameters
      ----------
      h1 : sequence
          The first histogram.
      h2 : sequence
          The second histogram, same bins as ``h1``.
      
      Returns
      -------
      cosine : float
          Cosine simmilarity.
          
      Notes
      -----
      The resulting similarity ranges from -1 meaning exactly opposite, to 1 meaning
      exactly the same, with 0 usually indicating independence, and in-between values
      indicating intermediate similarity or dissimilarity.
      """
      h1, h2 = __prepare_histogram(h1, h2)
      return scipy.sum(h1 * h2) / math.sqrt(scipy.sum(scipy.square(h1)) * scipy.sum(scipy.square(h2)))