def drawGibbs(vals, temperature=1.0):
 if (temperature == 0):
  m = max(vals)
  best = []
  for (i, v) in enumerate(vals):
   if (v == m):
    best.append(i)
  return choice(best)
 else:
  temp = (vals / temperature)
  temp += (20 - max(temp))
  if (min(temp) < (-20)):
   for (i, v) in enumerate(temp):
    if (v < (-20)):
     temp[i] = (-20)
  temp = exp(temp)
  temp /= sum(temp)
  return drawIndex(temp)

def drawGibbs ( vals , temperature = 1.0 ) : if ( temperature == 0 ) : m = max ( vals ) best = [ ] for ( i , v ) in enumerate ( vals ) : if ( v == m ) : best . append ( i ) return choice ( best ) else : temp = ( vals / temperature ) temp += ( 20 - max ( temp ) ) if ( min ( temp ) < ( - 20 ) ) : for ( i , v ) in enumerate ( temp ) : if ( v < ( - 20 ) ) : temp [ i ] = ( - 20 ) temp = exp ( temp ) temp /= sum ( temp ) return drawIndex ( temp )
return the index of the sample drawn by a softmax .