@@ -466,24 +466,24 @@ def __init__(self, mean=0, sigma=1, name=''):
466
466
# will get model's name prefix
467
467
468
468
# 3) you can create variables with Var method
469
- self.Var('v1', Normal.dist(mu=mean, sigma=sd) )
470
- # this will create variable named like '{prefix ::}v1'
469
+ self.register_rv(pm. Normal.dist(mu=mean, sigma=sigma), 'v1', initval=1 )
470
+ # this will create variable named like '{name ::}v1'
471
471
# and assign attribute 'v1' to instance created
472
472
# variable can be accessed with self.v1 or self['v1']
473
473
474
474
# 4) this syntax will also work as we are in the
475
475
# context of instance itself, names are given as usual
476
- Normal('v2', mu=mean, sigma=sd)
476
+ pm. Normal('v2', mu=mean, sigma=sigma
477
477
478
478
# something more complex is allowed, too
479
- half_cauchy = HalfCauchy('sigma ', beta=10, initval=1.)
480
- Normal('v3', mu=mean, sigma=half_cauchy)
479
+ half_cauchy = pm. HalfCauchy('sd ', beta=10, initval=1.)
480
+ pm. Normal('v3', mu=mean, sigma=half_cauchy)
481
481
482
482
# Deterministic variables can be used in usual way
483
- Deterministic('v3_sq', self.v3 ** 2)
483
+ pm. Deterministic('v3_sq', self.v3 ** 2)
484
484
485
485
# Potentials too
486
- Potential('p1', at.constant(1))
486
+ pm. Potential('p1', at.constant(1))
487
487
488
488
# After defining a class CustomModel you can use it in several
489
489
# ways
@@ -497,7 +497,7 @@ def __init__(self, mean=0, sigma=1, name=''):
497
497
# II:
498
498
# use new class as entering point in context
499
499
with CustomModel() as model:
500
- Normal('new_normal_var', mu=1, sigma=0)
500
+ pm. Normal('new_normal_var', mu=1, sigma=0)
501
501
502
502
# III:
503
503
# just get model instance with all that was defined in it
@@ -510,7 +510,6 @@ def __init__(self, mean=0, sigma=1, name=''):
510
510
CustomModel(mean=2, name='second')
511
511
512
512
# variables inside both scopes will be named like `first::*`, `second::*`
513
-
514
513
"""
515
514
516
515
if TYPE_CHECKING :
0 commit comments