def avgFoundAfter(decreasingTargetValues, listsOfActualValues, batchSize=1, useMedian=False):
 from scipy import sum
 numLists = len(listsOfActualValues)
 longest = max(list(map(len, listsOfActualValues)))
 res = [[0] for _ in range(numLists)]
 for tval in decreasingTargetValues:
  for (li, l) in enumerate(listsOfActualValues):
   lres = res[li]
   found = False
   for i in range(lres[(-1)], len(l)):
    if (l[i] <= tval):
     lres.append(i)
     found = True
     break
   if (not found):
    lres.append(longest)
 tmp = array(res)
 if useMedian:
  resx = median(tmp, axis=0)[1:]
 else:
  resx = (sum(tmp, axis=0)[1:] / float(numLists))
 return (resx * batchSize)

def avgFoundAfter ( decreasingTargetValues , listsOfActualValues , batchSize = 1 , useMedian = False ) : from scipy import sum numLists = len ( listsOfActualValues ) longest = max ( list ( map ( len , listsOfActualValues ) ) ) res = [ [ 0 ] for _ in range ( numLists ) ] for tval in decreasingTargetValues : for ( li , l ) in enumerate ( listsOfActualValues ) : lres = res [ li ] found = False for i in range ( lres [ ( - 1 ) ] , len ( l ) ) : if ( l [ i ] <= tval ) : lres . append ( i ) found = True break if ( not found ) : lres . append ( longest ) tmp = array ( res ) if useMedian : resx = median ( tmp , axis = 0 ) [ 1 : ] else : resx = ( sum ( tmp , axis = 0 ) [ 1 : ] / float ( numLists ) ) return ( resx * batchSize )
determine the average number of steps to reach a certain value .