#NEWLINE# def _sparseness( x ) : #NEWLINE# #INDENT# "Hoyer's measure of sparsity for a vector" #NEWLINE# sqrt_n = np . sqrt ( len ( x ) ) #NEWLINE# return ( ( sqrt_n - ( np . linalg . norm ( x , 1 ) / norm ( x ) ) ) / ( sqrt_n - 1 ) )