def sample_bernoulli_tanh(self, target=None):
    """
    Sample a bernoulli distribution. Choose 1 with probability given by entries of (1+self)/2, -1 otherwise.
    """
    if not target:
     target = self
    err_code = _eigenmat.sample_bernoulli_tanh(EigenMatrix.rnd_state_p, self.p_mat, target.p_mat)
    if err_code:
      raise generate_exception(err_code)

    return self

    Sample a bernoulli distribution. Choose 1 with probability given by entries of (1+self)/2, -1 otherwise.
    
eigenmat/eigenmat.py