class Q0(Q0_Base): """ Define prior """ def __init__(self): """ Define prior pdfs over stiffness, damping, and noise std. """ self.p_k = Normal_PDF(mean=3, cov=0.5) self.p_c = Gamma_PDF(a=1, scale=0.1) self.p_sigma = Gamma_PDF(a=1, scale=0.1) def logpdf(self, x): # Convert to 2D array if currently 1D if len(np.shape(x)) == 1: x = np.array([x]) # Calculate logpdf logpdf = (self.p_k.logpdf(x[:, 0]) + self.p_c.logpdf(x[:, 1]) + self.p_sigma.logpdf(x[:, 2])) return logpdf def rvs(self, size): k = np.vstack(self.p_k.rvs(size)) c = np.vstack(self.p_c.rvs(size)) sigma = np.vstack(self.p_sigma.rvs(size)) return np.hstack([k, c, sigma])
class Target(Target_Base): """ Define target """ def __init__(self): self.pdf = Normal_PDF(mean=np.array([3.0, 2.0]), cov=np.eye(2)) def logpdf(self, x): return self.pdf.logpdf(x)
class Target(Target_Base): """ Define target """ def __init__(self): self.pdf = Normal_PDF(mean=np.repeat(2, D), cov=0.1*np.eye(D)) def logpdf(self, x): return self.pdf.logpdf(x)
class Q0(Q0_Base): """ Define initial proposal """ def __init__(self): self.pdf = Normal_PDF(mean=np.zeros(2), cov=np.eye(2)) def logpdf(self, x): return self.pdf.logpdf(x) def rvs(self, size): return self.pdf.rvs(size)