def bernoulli_prob(var, bias=0.5):
  """ Returns Sympy-expression of a Bernoulli PMF for var at specified bias.

  :param var: boolean symbol to express pmf
  :param bias: bias probability (float ranging from 0 to 1).

  :return bias*var + (1-bias)*(1-var)
  """
  # bv + (1-b)(1-v) = bv + 1 - v - b + bv = 2bv - v - b + 1 = v(2b-1) + (1-b)
  return var * (2*bias - 1) + (1 - bias)