예제 #1
0
 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))
예제 #2
0
 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)
예제 #3
0
 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
예제 #4
0
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
예제 #5
0
    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)
예제 #6
0
 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,
     )
예제 #7
0
 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,
     )
예제 #8
0
 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
예제 #9
0
 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)
예제 #10
0
 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
예제 #11
0
 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)
예제 #12
0
 def a_model():
     try:
         yield 1
     except:
         pass
     yield pm.HalfNormal("n", 1, transform=pm.distributions.transforms.Log())
예제 #13
0
 def a_model():
     return (yield pm.HalfNormal("n", 1, transform=pm.distributions.transforms.Log()))
예제 #14
0
 def invdalid_model():
     yield pm.HalfNormal("n", 1, transform=pm.distributions.transforms.Log())
     yield pm.Normal("n", 0, 1)