def model(): a = yield pm.Normal("a", 0, 1) b = yield pm.HalfNormal("b", 1) c = yield pm.Normal("c", loc=a, scale=b, event_stack=len(observed_value))
def model(): mu = yield pm.Normal("mu", tf.zeros(4), 1) scale = yield pm.HalfNormal("scale", 1) x = yield pm.Normal("x", mu, scale, batch_stack=5, observed=observed)
def model(): sd = yield pm.Exponential("sd", 1) x = yield pm.Normal("x", 0, 1, observed=observed_kwargs["model/x"]) y = yield pm.HalfNormal("y", 1, observed=observed_kwargs["model/y"]) d = yield pm.Deterministic("d", x + y) z = yield pm.Normal("z", d, sd, observed=observed_kwargs["model/z"]) u = yield pm.Exponential("u", z) return u
def schools_pm4(): eta = yield pm4.Normal("eta", 0, 1, plate=J) mu = yield pm4.Normal("mu", 1, 10) tau = yield pm4.HalfNormal("tau", 1 * 2.0) theta = mu + tau * eta obs = yield pm4.Normal("obs", theta, sigma, observed=y) return obs
def linreg(n_points=100): # Define priors sigma = pm.HalfNormal("sigma", scale=10) intercept = pm.Normal("intercept", 0, scale=10) x_coeff = pm.Normal("weight", 0, scale=5) x = np.linspace(-5, 5, n_points) # Define likelihood y = pm.Normal("y", loc=intercept + x_coeff * x, scale=sigma)
def model(): mu = yield pm.Normal( "mu", tf.zeros(4), 1, conditionally_independent=True, reinterpreted_batch_ndims=1, ) scale = yield pm.HalfNormal("scale", 1, conditionally_independent=True) x = yield pm.Normal( "x", mu, scale[..., None], observed=observed, reinterpreted_batch_ndims=1, event_stack=5, )
def model(): beta = yield pm.Normal( "beta", tf.zeros((n_features, )), 1, conditionally_independent=True, reinterpreted_batch_ndims=1, ) bias = yield pm.Normal("bias", 0, 1, conditionally_independent=True) scale = yield pm.HalfNormal("scale", 1, conditionally_independent=True) mu = tf.linalg.matvec(regressors, beta) + bias[..., None] y = yield pm.Normal( "y", mu, scale[..., None], observed=observed, reinterpreted_batch_ndims=1, )
def outer_model(): cond = yield pm.HalfNormal("cond", 1) dcond = yield pm.Deterministic("dcond", cond * 2) dx = yield nested_model(dcond) ddx = yield pm.Deterministic("ddx", dx) return ddx
def model(): sd = yield pm.HalfNormal("sd", 1.0) mu = yield pm.Deterministic("mu", tf.convert_to_tensor(1.0)) x = yield pm.Normal("x", mu, sd, observed=observed) y = yield pm.Normal("y", x, 1e-9) dy = yield pm.Deterministic("dy", 2 * y)
def outer_model(): cond = yield pm.HalfNormal("cond", 1, conditionally_independent=True) dcond = yield pm.Deterministic("dcond", cond * 2) dx = yield nested_model(dcond) ddx = yield pm.Deterministic("ddx", dx) return ddx
def model(): beta = yield pm.Normal("beta", tf.zeros((n_features, )), 1) bias = yield pm.Normal("bias", 0, 1) scale = yield pm.HalfNormal("scale", 1) mu = tf.linalg.matvec(regressors, beta) + bias y = yield pm.Normal("y", mu, scale, observed=observed)
def a_model(): try: yield 1 except: pass yield pm.HalfNormal("n", 1, transform=pm.distributions.transforms.Log())
def a_model(): return (yield pm.HalfNormal("n", 1, transform=pm.distributions.transforms.Log()))
def invdalid_model(): yield pm.HalfNormal("n", 1, transform=pm.distributions.transforms.Log()) yield pm.Normal("n", 0, 1)