class_docstr: Metropolis-Hastings optimized for binary variables
  
  Parameters
  ----------
  scaling : scalar or array
      Initial scale factor for proposal. Defaults to 1.
class_docstr_tok: ["Metropolis-Hastings","optimized","for","binary","variables","Parameters","--","--","--","--","--","scaling",":","scalar","or","array","Initial","scale","factor","for","proposal",".","Defaults","to","1","."]
docstr: Helper function which implements binary metropolis sampler.
docstr_tok: ["Helper","function","which","implements","binary","metropolis","sampler","."]
code: def _sample(self, q0):
      """
      Helper function which implements binary metropolis sampler.
      """
      # Convert adaptive_scale_factor to a jump probability
      p_jump = 1.0 - 0.5**self.scaling
  
      rand_array = nr.random(q0.shape)
      q = np.copy(q0)
  
      # Locations where switches occur, according to p_jump
      switch_locs = rand_array < p_jump
      q[switch_locs] = True - q[switch_locs]
  
      accept = self.model.logp(q) - self.model.logp(q0)
      q_new, _ = metrop_select(np.exp(accept), q, q0)
  
      return q_new
  
imports: from __future__ import division
  import scipy.linalg
  import numpy
  import numpy.random
label_desc: Use image node_id 2 for calling the BinaryMetropolis obj's underlying member method code with example usage: obj._sample(q0) and returns: q_new