estimate the variance explained by K

def variance_K(K, verbose=False):
    """estimate the variance explained by K"""
    c = SP.sum((SP.eye(len(K)) - (1.0 / len(K)) * SP.ones(K.shape)) * SP.array(K))
    scalar = (len(K) - 1) / c
    return 1.0/scalar