#NEWLINE# def inconsistent( Z , d = 2 ) : #NEWLINE# #INDENT# "\n    Calculates inconsistency statistics on a linkage.\n\n    Note: This function behaves similarly to the MATLAB(TM)\n    inconsistent function.\n\n    Parameters\n    ----------\n    Z : ndarray\n        The :math:`(n-1)` by 4 matrix encoding the linkage (hierarchical\n        clustering).  See `linkage` documentation for more information on its\n        form.\n    d : int, optional\n        The number of links up to `d` levels below each non-singleton cluster.\n\n    Returns\n    -------\n    R : ndarray\n        A :math:`(n-1)` by 5 matrix where the ``i``'th row contains the link\n        statistics for the non-singleton cluster ``i``. The link statistics are\n        computed over the link heights for links :math:`d` levels below the\n        cluster ``i``. ``R[i,0]`` and ``R[i,1]`` are the mean and standard\n        deviation of the link heights, respectively; ``R[i,2]`` is the number\n        of links included in the calculation; and ``R[i,3]`` is the\n        inconsistency coefficient,\n\n        .. math:: \\frac{\\mathtt{Z[i,2]} - \\mathtt{R[i,0]}} {R[i,1]}\n\n    " #NEWLINE# Z = np . asarray ( Z , order = 'c' ) #NEWLINE# Zs = d . shape #NEWLINE# is_valid_linkage ( Z , throw = True , name = 'Z' ) #NEWLINE# if ( ( not ( d == np . floor ( d ) ) ) or ( d < 0 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'The second argument d must be a nonnegative integer value.' ) #NEWLINE# #UNINDENT# [ Z ] = _copy_arrays_if_base_present ( [ Z ] ) #NEWLINE# n = ( Zs [ 0 ] + 1 ) #NEWLINE# R = np . zeros ( ( ( n - 1 ) , 4 ) , dtype = np . double ) #NEWLINE# _hierarchy . inconsistent ( Z , R , int ( n ) , int ( d ) ) #NEWLINE# return R