parameters: (rankvals)
return_statement: return 1.0 if size < 2 else 1.0 - (cnt**3 - cnt).sum() / (size**3 - size)
docstring: Tie correction factor for ties in the Mann-Whitney U and
      Kruskal-Wallis H tests.
  
      Parameters
      ----------
      rankvals : array_like
          A 1-D sequence of ranks.  Typically this will be the array
          returned by `stats.rankdata`.
  
      Returns
      -------
      factor : float
          Correction factor for U or H.
  
      See Also
      --------
      rankdata : Assign ranks to the data
      mannwhitneyu : Mann-Whitney rank test
      kruskal : Kruskal-Wallis H test
  
      References
      ----------
      .. [1] Siegel, S. (1956) Nonparametric Statistics for the Behavioral
             Sciences.  New York: McGraw-Hill.
  
      Examples
      --------
      >>> from scipy.stats import tiecorrect, rankdata
      >>> tiecorrect([1, 2.5, 2.5, 4])
      0.9
      >>> ranks = rankdata([1, 3, 2, 4, 5, 7, 2, 8, 4])
      >>> ranks
      array([ 1. ,  4. ,  2.5,  5.5,  7. ,  8. ,  2.5,  9. ,  5.5])
      >>> tiecorrect(ranks)
      0.9833333333333333
docstring_summary: Tie correction factor for ties in the Mann-Whitney U and
      Kruskal-Wallis H tests.
docstring_tokens: Tie correction factor for ties in the Mann - Whitney U and Kruskal - Wallis H tests .
function: def tiecorrect(rankvals):
      """
      Tie correction factor for ties in the Mann-Whitney U and
      Kruskal-Wallis H tests.
  
      Parameters
      ----------
      rankvals : array_like
          A 1-D sequence of ranks.  Typically this will be the array
          returned by `stats.rankdata`.
  
      Returns
      -------
      factor : float
          Correction factor for U or H.
  
      See Also
      --------
      rankdata : Assign ranks to the data
      mannwhitneyu : Mann-Whitney rank test
      kruskal : Kruskal-Wallis H test
  
      References
      ----------
      .. [1] Siegel, S. (1956) Nonparametric Statistics for the Behavioral
             Sciences.  New York: McGraw-Hill.
  
      Examples
      --------
      >>> from scipy.stats import tiecorrect, rankdata
      >>> tiecorrect([1, 2.5, 2.5, 4])
      0.9
      >>> ranks = rankdata([1, 3, 2, 4, 5, 7, 2, 8, 4])
      >>> ranks
      array([ 1. ,  4. ,  2.5,  5.5,  7. ,  8. ,  2.5,  9. ,  5.5])
      >>> tiecorrect(ranks)
      0.9833333333333333
  
      """
      arr = np.sort(rankvals)
      idx = np.nonzero(np.r_[True, arr[1:] != arr[:-1], True])[0]
      cnt = np.diff(idx).astype(np.float64)
  
      size = np.float64(arr.size)
      return 1.0 if size < 2 else 1.0 - (cnt**3 - cnt).sum() / (size**3 - size)
function_tokens: def tiecorrect ( rankvals ) : arr = np . sort ( rankvals ) idx = np . nonzero ( np . r_ [ True , arr [ 1 : ] != arr [ : - 1 ] , True ] ) [ 0 ] cnt = np . diff ( idx ) . astype ( np . float64 ) size = np . float64 ( arr . size ) return 1.0 if size < 2 else 1.0 - ( cnt ** 3 - cnt ) . sum ( ) / ( size ** 3 - size )