original_docstring:  Calculates the Schreiber et al. similarity measure between spike
      trains given a kernel.
  
      Let :math:`v_a(t)` and :math:`v_b(t)` with :math:`t \\in \\mathcal{T}` be
      the spike trains convolved with some smoothing filter and :math:`V(a, b)
      = \\int_{\\mathcal{T}} v_a(t) v_b(t) dt`. The autocorrelation of the
      smoothing filter corresponds to the kernel used to analytically calculate
      the Schreiber et al. similarity measure. It is defined as :math:`S_{S}(a,
      b) = \\frac{V(a, b)}{\\sqrt{V(a, a) V(b, b)}}`. It is closely related to
      the Cauchy-Schwarz distance :math:`d_{CS}` by :math:`S_S = \\sqrt{\\cos
      d_{CS}}`.
  
      In opposite to :func:`cs_dist` which numerically convolves the spike trains
      with a smoothing filter, this function directly uses the kernel resulting
      from the smoothing filter's autocorrelation. This allows a more accurate
      and faster calculation.
  
      Further information can be found in:
  
      - *Dauwels, J., Vialatte, F., Weber, T., & Cichocki, A. (2009). On
        similarity measures for spike trains. Advances in Neuro-Information
        Processing, 177-185.*
      - *Paiva, A. R. C., Park, I., & Principe, J. C. (2009). A comparison of
        binless spike train measures. Neural Computing and Applications, 19(3),
        405-419. doi:10.1007/s00521-009-0307-6*
  
      :param sequence trains: Sequence of :class:`neo.core.SpikeTrain` objects of
          which the distance will be calculated pairwise.
      :param kernel: Kernel to use. It corresponds to a smoothing filter
          by being the autocorrelation of such a filter.
      :type kernel: :class:`.signal_processing.Kernel`
      :param bool sort: Spike trains with sorted spike times will be needed for
          the calculation. You can set `sort` to `False` if you know that your
          spike trains are already sorted to decrease calculation time.
      :returns: Matrix containing the Schreiber et al. similarity measure of all
          pairs of spike trains.
      :rtype: 2-D array
      
docstring: Calculates the Schreiber et al. similarity measure between spike
  trains given a kernel.
  
  
  
  In opposite to :func:`cs_dist` which numerically convolves the spike trains
  with a smoothing filter, this function directly uses the kernel resulting
  from the smoothing filter's autocorrelation. This allows a more accurate
  and faster calculation.
  
  Further information can be found in.
  
  *Dauwels, J., Vialatte, F., Weber, T., & Cichocki, A.
docstring_tokens: Calculates the Schreiber et al . similarity measure between spike trains given a kernel . In opposite to : func : ` cs_dist ` which numerically convolves the spike trains with a smoothing filter this function directly uses the kernel resulting from the smoothing filter ' s autocorrelation . This allows a more accurate and faster calculation . Further information can be found in . * Dauwels J . Vialatte F . Weber T . & Cichocki A .
code: def schreiber_similarity(trains, kernel, sort=True):
      """ Calculates the Schreiber et al. similarity measure between spike
      trains given a kernel.
  
      Let :math:`v_a(t)` and :math:`v_b(t)` with :math:`t \\in \\mathcal{T}` be
      the spike trains convolved with some smoothing filter and :math:`V(a, b)
      = \\int_{\\mathcal{T}} v_a(t) v_b(t) dt`. The autocorrelation of the
      smoothing filter corresponds to the kernel used to analytically calculate
      the Schreiber et al. similarity measure. It is defined as :math:`S_{S}(a,
      b) = \\frac{V(a, b)}{\\sqrt{V(a, a) V(b, b)}}`. It is closely related to
      the Cauchy-Schwarz distance :math:`d_{CS}` by :math:`S_S = \\sqrt{\\cos
      d_{CS}}`.
  
      In opposite to :func:`cs_dist` which numerically convolves the spike trains
      with a smoothing filter, this function directly uses the kernel resulting
      from the smoothing filter's autocorrelation. This allows a more accurate
      and faster calculation.
  
      Further information can be found in:
  
      - *Dauwels, J., Vialatte, F., Weber, T., & Cichocki, A. (2009). On
        similarity measures for spike trains. Advances in Neuro-Information
        Processing, 177-185.*
      - *Paiva, A. R. C., Park, I., & Principe, J. C. (2009). A comparison of
        binless spike train measures. Neural Computing and Applications, 19(3),
        405-419. doi:10.1007/s00521-009-0307-6*
  
      :param sequence trains: Sequence of :class:`neo.core.SpikeTrain` objects of
          which the distance will be calculated pairwise.
      :param kernel: Kernel to use. It corresponds to a smoothing filter
          by being the autocorrelation of such a filter.
      :type kernel: :class:`.signal_processing.Kernel`
      :param bool sort: Spike trains with sorted spike times will be needed for
          the calculation. You can set `sort` to `False` if you know that your
          spike trains are already sorted to decrease calculation time.
      :returns: Matrix containing the Schreiber et al. similarity measure of all
          pairs of spike trains.
      :rtype: 2-D array
      """
  
      k_dist = kernel.summed_dist_matrix(trains, not sort)
  
      def compute(i, j):
          return sp.sqrt(
              k_dist[i, j] * k_dist[j, i] / k_dist[i, i] / k_dist[j, j])
  
      return _create_matrix_from_indexed_function(
          (len(trains), len(trains)), compute, kernel.is_symmetric())
code_tokens: def schreiber_similarity ( trains , kernel , sort = True ) : k_dist = kernel . summed_dist_matrix ( trains , not sort ) def compute ( i , j ) : return sp . sqrt ( k_dist [ i , j ] * k_dist [ j , i ] / k_dist [ i , i ] / k_dist [ j , j ] ) return _create_matrix_from_indexed_function ( ( len ( trains ) , len ( trains ) ) , compute , kernel . is_symmetric ( ) )
short_docstring: Calculates the Schreiber et al.
short_docstring_tokens: Calculates the Schreiber et al .
comment: """ Calculates the Schreiber et al. similarity measure between spike
      trains given a kernel.
  
      Let :math:`v_a(t)` and :math:`v_b(t)` with :math:`t \\in \\mathcal{T}` be
      the spike trains convolved with some smoothing filter and :math:`V(a, b)
      = \\int_{\\mathcal{T}} v_a(t) v_b(t) dt`. The autocorrelation of the
      smoothing filter corresponds to the kernel used to analytically calculate
      the Schreiber et al. similarity measure. It is defined as :math:`S_{S}(a,
      b) = \\frac{V(a, b)}{\\sqrt{V(a, a) V(b, b)}}`. It is closely related to
      the Cauchy-Schwarz distance :math:`d_{CS}` by :math:`S_S = \\sqrt{\\cos
      d_{CS}}`.
  
      In opposite to :func:`cs_dist` which numerically convolves the spike trains
      with a smoothing filter, this function directly uses the kernel resulting
      from the smoothing filter's autocorrelation. This allows a more accurate
      and faster calculation.
  
      Further information can be found in:
  
      - *Dauwels, J., Vialatte, F., Weber, T., & Cichocki, A. (2009). On
        similarity measures for spike trains. Advances in Neuro-Information
        Processing, 177-185.*
      - *Paiva, A. R. C., Park, I., & Principe, J. C. (2009). A comparison of
        binless spike train measures. Neural Computing and Applications, 19(3),
        405-419. doi:10.1007/s00521-009-0307-6*
  
      :param sequence trains: Sequence of :class:`neo.core.SpikeTrain` objects of
          which the distance will be calculated pairwise.
      :param kernel: Kernel to use. It corresponds to a smoothing filter
          by being the autocorrelation of such a filter.
      :type kernel: :class:`.signal_processing.Kernel`
      :param bool sort: Spike trains with sorted spike times will be needed for
          the calculation. You can set `sort` to `False` if you know that your
          spike trains are already sorted to decrease calculation time.
      :returns: Matrix containing the Schreiber et al. similarity measure of all
          pairs of spike trains.
      :rtype: 2-D array
      """