original_docstring:  Calculates the van Rossum distance.
  
      It is defined as Euclidean distance of the spike trains convolved with a
      causal decaying exponential smoothing filter. A detailed description can be
      found in *Rossum, M. C. W. (2001). A novel spike distance. Neural
      Computation, 13(4), 751-763.* This implementation is normalized to yield
      a distance of 1.0 for the distance between an empty spike train and a spike
      train with a single spike. Divide the result by sqrt(2.0) to get the
      normalization used in the cited paper.
  
      Given :math:`N` spike trains with :math:`n` spikes on average the run-time
      complexity of this function is :math:`O(N^2 n^2)`. An implementation in
      :math:`O(N^2 n)` would be possible but has a high constant factor rendering
      it slower in practical cases.
  
      :param sequence trains: Sequence of :class:`neo.core.SpikeTrain` objects of
          which the van Rossum distance will be calculated pairwise.
      :param tau: Decay rate of the exponential function as time scalar. Controls
          for which time scale the metric will be sensitive. This parameter will
          be ignored if `kernel` is not `None`. May also be :const:`scipy.inf`
          which will lead to only measuring differences in spike count.
      :type tau: Quantity scalar
      :param kernel: Kernel to use in the calculation of the distance. This is not
          the smoothing filter, but its autocorrelation. If `kernel` is `None`, an
          unnormalized Laplacian kernel with a size of `tau` will be used.
      :type kernel: :class:`.signal_processing.Kernel`
      :param bool sort: Spike trains with sorted spike times might 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 van Rossum distances for all pairs of spike
          trains.
      :rtype: 2-D array
      
docstring: Calculates the van Rossum distance.
  It is defined as Euclidean distance of the spike trains convolved with a
  causal decaying exponential smoothing filter. A detailed description can be
  found in *Rossum, M. C. W.
  
  
docstring_tokens: Calculates the van Rossum distance . It is defined as Euclidean distance of the spike trains convolved with a causal decaying exponential smoothing filter . A detailed description can be found in * Rossum M . C . W .
code: def van_rossum_dist(trains, tau=1.0 * pq.s, kernel=None, sort=True):
      """ Calculates the van Rossum distance.
  
      It is defined as Euclidean distance of the spike trains convolved with a
      causal decaying exponential smoothing filter. A detailed description can be
      found in *Rossum, M. C. W. (2001). A novel spike distance. Neural
      Computation, 13(4), 751-763.* This implementation is normalized to yield
      a distance of 1.0 for the distance between an empty spike train and a spike
      train with a single spike. Divide the result by sqrt(2.0) to get the
      normalization used in the cited paper.
  
      Given :math:`N` spike trains with :math:`n` spikes on average the run-time
      complexity of this function is :math:`O(N^2 n^2)`. An implementation in
      :math:`O(N^2 n)` would be possible but has a high constant factor rendering
      it slower in practical cases.
  
      :param sequence trains: Sequence of :class:`neo.core.SpikeTrain` objects of
          which the van Rossum distance will be calculated pairwise.
      :param tau: Decay rate of the exponential function as time scalar. Controls
          for which time scale the metric will be sensitive. This parameter will
          be ignored if `kernel` is not `None`. May also be :const:`scipy.inf`
          which will lead to only measuring differences in spike count.
      :type tau: Quantity scalar
      :param kernel: Kernel to use in the calculation of the distance. This is not
          the smoothing filter, but its autocorrelation. If `kernel` is `None`, an
          unnormalized Laplacian kernel with a size of `tau` will be used.
      :type kernel: :class:`.signal_processing.Kernel`
      :param bool sort: Spike trains with sorted spike times might 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 van Rossum distances for all pairs of spike
          trains.
      :rtype: 2-D array
      """
  
      if kernel is None:
          if tau == sp.inf:
              spike_counts = [st.size for st in trains]
              return (spike_counts - sp.atleast_2d(spike_counts).T) ** 2
          kernel = sigproc.LaplacianKernel(tau, normalize=False)
  
      k_dist = kernel.summed_dist_matrix(
          [st.view(type=pq.Quantity) for st in trains], not sort)
      vr_dist = sp.empty_like(k_dist)
      for i, j in sp.ndindex(*k_dist.shape):
          vr_dist[i, j] = (
              k_dist[i, i] + k_dist[j, j] - k_dist[i, j] - k_dist[j, i])
      return sp.sqrt(vr_dist)
code_tokens: def van_rossum_dist ( trains , tau = 1.0 * pq . s , kernel = None , sort = True ) : if kernel is None : if tau == sp . inf : spike_counts = [ st . size for st in trains ] return ( spike_counts - sp . atleast_2d ( spike_counts ) . T ) ** 2 kernel = sigproc . LaplacianKernel ( tau , normalize = False ) k_dist = kernel . summed_dist_matrix ( [ st . view ( type = pq . Quantity ) for st in trains ] , not sort ) vr_dist = sp . empty_like ( k_dist ) for i , j in sp . ndindex ( * k_dist . shape ) : vr_dist [ i , j ] = ( k_dist [ i , i ] + k_dist [ j , j ] - k_dist [ i , j ] - k_dist [ j , i ] ) return sp . sqrt ( vr_dist )
short_docstring: Calculates the van Rossum distance.
short_docstring_tokens: Calculates the van Rossum distance .
comment: """ Calculates the van Rossum distance.
  
      It is defined as Euclidean distance of the spike trains convolved with a
      causal decaying exponential smoothing filter. A detailed description can be
      found in *Rossum, M. C. W. (2001). A novel spike distance. Neural
      Computation, 13(4), 751-763.* This implementation is normalized to yield
      a distance of 1.0 for the distance between an empty spike train and a spike
      train with a single spike. Divide the result by sqrt(2.0) to get the
      normalization used in the cited paper.
  
      Given :math:`N` spike trains with :math:`n` spikes on average the run-time
      complexity of this function is :math:`O(N^2 n^2)`. An implementation in
      :math:`O(N^2 n)` would be possible but has a high constant factor rendering
      it slower in practical cases.
  
      :param sequence trains: Sequence of :class:`neo.core.SpikeTrain` objects of
          which the van Rossum distance will be calculated pairwise.
      :param tau: Decay rate of the exponential function as time scalar. Controls
          for which time scale the metric will be sensitive. This parameter will
          be ignored if `kernel` is not `None`. May also be :const:`scipy.inf`
          which will lead to only measuring differences in spike count.
      :type tau: Quantity scalar
      :param kernel: Kernel to use in the calculation of the distance. This is not
          the smoothing filter, but its autocorrelation. If `kernel` is `None`, an
          unnormalized Laplacian kernel with a size of `tau` will be used.
      :type kernel: :class:`.signal_processing.Kernel`
      :param bool sort: Spike trains with sorted spike times might 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 van Rossum distances for all pairs of spike
          trains.
      :rtype: 2-D array
      """