def mean_quadratic_weighted_kappa(kappas, weights=None):
 kappas = np.array(kappas, dtype=float)
 if (weights is None):
  weights = np.ones(np.shape(kappas))
 else:
  weights = (weights / np.mean(weights))
 kappas = np.array([min(x, 0.999) for x in kappas])
 kappas = np.array([max(x, (-0.999)) for x in kappas])
 z = ((0.5 * np.log(((1 + kappas) / (1 - kappas)))) * weights)
 z = np.mean(z)
 return ((np.exp((2 * z)) - 1) / (np.exp((2 * z)) + 1))

def mean_quadratic_weighted_kappa ( kappas , weights = None ) : kappas = np . array ( kappas , dtype = float ) if ( weights is None ) : weights = np . ones ( np . shape ( kappas ) ) else : weights = ( weights / np . mean ( weights ) ) kappas = np . array ( [ min ( x , 0.999 ) for x in kappas ] ) kappas = np . array ( [ max ( x , ( - 0.999 ) ) for x in kappas ] ) z = ( ( 0.5 * np . log ( ( ( 1 + kappas ) / ( 1 - kappas ) ) ) ) * weights ) z = np . mean ( z ) return ( ( np . exp ( ( 2 * z ) ) - 1 ) / ( np . exp ( ( 2 * z ) ) + 1 ) )
calculates the mean of the quadratic weighted kappas after applying fishers r-to-z transform .