class_docstr: Metropolis-Hastings sampling step
  
  Parameters
  ----------
  S : standard deviation or covariance matrix
    Some measure of variance to parameterize proposal distribution
  proposal_dist : function
    Function that returns zero-mean deviates when parameterized with
    S (and n). Defaults to normal.
  scaling : scalar or array
    Initial scale factor for proposal. Defaults to 1.
  tune : bool
    Flag for tuning. Defaults to True.
  tune_interval : int
    The frequency of tuning. Defaults to 100 iterations.
class_docstr_tok: ["Metropolis-Hastings","sampling","step","Parameters","--","--","--","--","--","S",":","standard","deviation","or","covariance","matrix","Some","measure","of","variance","to","parameterize","proposal","distribution","proposal_dist",":","function","Function","that","returns","zero-mean","deviates","when","parameterized","with","S","(","and","n",")",".","Defaults","to","normal",".","scaling",":","scalar","or","array","Initial","scale","factor","for","proposal",".","Defaults","to","1.","tune",":","bool","Flag","for","tuning",".","Defaults","to","True",".","tune_interval",":","int","The","frequency","of","tuning",".","Defaults","to","100","iterations","."]
docstr: Helper function which implements metropolis sampler.
docstr_tok: ["Helper","function","which","implements","metropolis","sampler","."]
code: def _sample(self, q0):
      """
      Helper function which implements metropolis sampler.
      """
      if not self.steps_until_tune and self.tune:
          # Tune scaling parameter
          self.scaling = tune_params(
              self.scaling, self.accepted / float(self.tune_interval)
          )
          # Reset counter
          self.steps_until_tune = self.tune_interval
          self.accepted = 0
  
      delta = self.proposal_dist() * self.scaling
      if self.discrete:
          delta = np.round(delta, 0).astype("int64")
          q0 = q0.astype("int64")
          q = (q0 + delta).astype("int64")
      else:
          q = q0 + delta
  
      accept = delta_logp(self.model, q, q0)
      q_new, accepted = metrop_select(accept, q, q0)
      self.accepted += accepted
  
      self.steps_until_tune -= 1
  
      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 Metropolis obj's underlying member method code with example usage: obj._sample(q0) and returns: q_new