def get_elements_count(N, N1, W2):
 thresh = 0.9
 max_count = 0
 total_counts = 0.0
 for i in xrange(N):
  w = W2[:, i]
  wa = np.abs(w)
  total = wa.sum()
  s = np.asarray(sorted(wa))
  count = 1
  while (s[(- count):].sum() < (thresh * total)):
   count += 1
  if (count > max_count):
   max_count = count
  total_counts += count
 ave = (total_counts / float(N))
 print('average needed filters', ave)
 count = max_count
 print('It takes', count, 'of', N1, 'elements to account for ', (thresh * 100.0), '\\% of the weight in at least one filter')
 lim = 10
 if (count > lim):
  count = lim
  print('Only displaying ', count, ' elements though.')
 if (count > N1):
  count = N1
 return count

def get_elements_count ( N , N1 , W2 ) : thresh = 0.9 max_count = 0 total_counts = 0.0 for i in xrange ( N ) : w = W2 [ : , i ] wa = np . abs ( w ) total = wa . sum ( ) s = np . asarray ( sorted ( wa ) ) count = 1 while ( s [ ( - count ) : ] . sum ( ) < ( thresh * total ) ) : count += 1 if ( count > max_count ) : max_count = count total_counts += count ave = ( total_counts / float ( N ) ) print ( 'average needed filters' , ave ) count = max_count print ( 'It takes' , count , 'of' , N1 , 'elements to account for ' , ( thresh * 100.0 ) , '\\% of the weight in at least one filter' ) lim = 10 if ( count > lim ) : count = lim print ( 'Only displaying ' , count , ' elements though.' ) if ( count > N1 ) : count = N1 return count
retrieve the number of elements to show .