def __init__(self, distribution, kernel, Z, threshold, spread): if not isinstance(distribution, Distribution): raise TypeError("Target must be a Distribution object") if not isinstance(kernel, Kernel): raise TypeError("Kernel must be a Kernel object") if not type(Z) is numpy.ndarray: raise TypeError("History must be a numpy array") if not len(Z.shape) == 2: raise ValueError("History must be a 2D numpy array") if not Z.shape[1] == distribution.dimension: raise ValueError( "History dimension does not match target dimension") if not Z.shape[0] > 0: raise ValueError("History must contain at least one point") if not type(threshold) is float: raise TypeError("Threshold must be a float") if not type(spread) is float: raise TypeError("Spread must be a float") if not (spread > 0. and spread < 1.): raise ValueError("Spread must be a probability") MCMCSampler.__init__(self, distribution) self.kernel = kernel self.Z = Z self.threshold = threshold self.spread = spread
def __init__(self, distribution, kernel, Z, threshold, spread): if not isinstance(distribution, Distribution): raise TypeError("Target must be a Distribution object") if not isinstance(kernel, Kernel): raise TypeError("Kernel must be a Kernel object") if not type(Z) is numpy.ndarray: raise TypeError("History must be a numpy array") if not len(Z.shape) == 2: raise ValueError("History must be a 2D numpy array") if not Z.shape[1] == distribution.dimension: raise ValueError("History dimension does not match target dimension") if not Z.shape[0] > 0: raise ValueError("History must contain at least one point") if not type(threshold) is float: raise TypeError("Threshold must be a float") if not type(spread) is float: raise TypeError("Spread must be a float") if not (spread > 0. and spread < 1.): raise ValueError("Spread must be a probability") MCMCSampler.__init__(self, distribution) self.kernel = kernel self.Z = Z self.threshold = threshold self.spread = spread
def __init__(self, full_conditionals): if not isinstance(full_conditionals, FullConditionals): raise TypeError("Gibbs require full conditional distribution instance") MCMCSampler.__init__(self, full_conditionals) # pdf is constant, and therefore symmetric self.is_symmetric = True
def __init__(self, distribution, kernel, Z, nu2=0.1, gamma=None): MCMCSampler.__init__(self, distribution) self.kernel = kernel self.nu2 = nu2 if gamma is not None: self.gamma = gamma else: self.gamma=0.2 self.Z = Z
def __init__(self, distribution, scale=None, cov=None): MCMCSampler.__init__(self, distribution) if scale is None: self.scale = (2.38 ** 2) / distribution.dimension else: self.scale = scale if cov is None: self.cov = eye(distribution.dimension) else: self.cov = cov
def __init__(self, distribution, scale=None, cov=None): MCMCSampler.__init__(self, distribution) if scale is None: self.scale = (2.38**2) / distribution.dimension else: self.scale = scale if cov is None: self.cov = eye(distribution.dimension) else: self.cov = cov
def __init__(self, distribution, spread, flip_at_least_one=True): if not isinstance(distribution, Distribution): raise TypeError("Target must be a Distribution object") if not type(spread) is float: raise TypeError("Spread must be a float") if not (spread > 0. and spread < 1.): raise ValueError("Spread must be a probability") MCMCSampler.__init__(self, distribution) self.spread = spread self.flip_at_least_one = flip_at_least_one
def __str__(self): s=self.__class__.__name__+ "=[" s += "kernel="+ str(self.kernel) s += ", nu2="+ str(self.nu2) s += ", gamma="+ str(self.gamma) s += ", " + MCMCSampler.__str__(self) s += "]" return s
def __str__(self): s = self.__class__.__name__ + "=[" s += "kernel=" + str(self.kernel) s += ", threshold=" + str(self.threshold) s += ", spread=" + str(self.spread) s += ", " + MCMCSampler.__str__(self) s += "]" return s
def __str__(self): s=self.__class__.__name__+ "=[" s += "globalscale="+ str(self.globalscale) s += ", sample_discard="+ str(self.sample_discard) s += ", sample_lag="+ str(self.sample_lag) s += ", accstar="+ str(self.accstar) s += ", " + MCMCSampler.__str__(self) s += "]" return s
def __init__(self, distribution, \ mean_est=None, cov_est=None, \ sample_discard=500, sample_lag=20, accstar=0.234): MCMCSampler.__init__(self, distribution) self.globalscale = (2.38 ** 2) / distribution.dimension if mean_est is None: mean_est=2*ones(distribution.dimension) if cov_est is None: cov_est=0.05 * eye(distribution.dimension) assert (len(mean_est) == distribution.dimension) assert (len(cov_est) == distribution.dimension) self.mean_est = mean_est self.cov_est = cov_est self.sample_discard = sample_discard self.sample_lag = sample_lag self.accstar = accstar
def __str__(self): s = self.__class__.__name__ + "=[" s += "spread=" + str(self.spread) s += ", " + MCMCSampler.__str__(self) s += "]" return s
def __str__(self): s = self.__class__.__name__ + "=[" s += "scale=" + str(self.scale) s += ", " + MCMCSampler.__str__(self) s += "]" return s
def __str__(self): s = self.__class__.__name__ + "=[" s += MCMCSampler.__str__(self) s += "]" return s