def logmgf_exact(q, priv_eps, l):
 if (q < 0.5):
  t_one = ((1 - q) * math.pow(((1 - q) / (1 - (math.exp(priv_eps) * q))), l))
  t_two = (q * math.exp((priv_eps * l)))
  t = (t_one + t_two)
  try:
   log_t = math.log(t)
  except ValueError:
   print ('Got ValueError in math.log for values :' + str((q, priv_eps, l, t)))
   log_t = (priv_eps * l)
 else:
  log_t = (priv_eps * l)
 return min(((((0.5 * priv_eps) * priv_eps) * l) * (l + 1)), log_t, (priv_eps * l))

def logmgf_exact ( q , priv_eps , l ) : if ( q < 0.5 ) : t_one = ( ( 1 - q ) * math . pow ( ( ( 1 - q ) / ( 1 - ( math . exp ( priv_eps ) * q ) ) ) , l ) ) t_two = ( q * math . exp ( ( priv_eps * l ) ) ) t = ( t_one + t_two ) try : log_t = math . log ( t ) except ValueError : print ( 'Got ValueError in math.log for values :' + str ( ( q , priv_eps , l , t ) ) ) log_t = ( priv_eps * l ) else : log_t = ( priv_eps * l ) return min ( ( ( ( ( 0.5 * priv_eps ) * priv_eps ) * l ) * ( l + 1 ) ) , log_t , ( priv_eps * l ) )
computes the logmgf value given q and privacy eps .