You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/lasso_block_update.py
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@
4
4
# <markdowncell>
5
5
6
6
# Sometimes, it is very useful to update a set of parameters together. For example, variables that are highly correlated are often good to update together. In PyMC 3 block updating is simple, as example will demonstrate.
7
-
#
7
+
#
8
8
# Here we have a LASSO regression model where the two coefficients are strongly correlated. Normally, we would define the coefficient parameters as a single random variable, but here we define them separately to show how to do block updates.
9
-
#
9
+
#
10
10
# First we generate some fake data.
11
11
12
12
# <codecell>
13
13
frommatplotlib.pylabimport*
14
-
frompymcimport*
15
-
importnumpyasnp
14
+
frompymcimport*
15
+
importnumpyasnp
16
16
17
17
d=np.random.normal(size=(3, 30))
18
18
d1=d[0] +4
@@ -29,24 +29,24 @@
29
29
s=Exponential('s', 1)
30
30
m1=Laplace('m1', 0, 100)
31
31
m2=Laplace('m2', 0, 100)
32
-
32
+
33
33
p=d1*m1+d2*m2
34
-
35
-
y=Normal('y', p, s**-2, observed=yd)
34
+
35
+
y=Normal('y', p, s**-2, observed=yd)
36
36
37
37
# <markdowncell>
38
38
39
-
# For most samplers, including Metropolis and HamiltonianMC, simply pass a list of variables to sample as a block. This works with both scalar and array parameters.
39
+
# For most samplers, including Metropolis and HamiltonianMC, simply pass a list of variables to sample as a block. This works with both scalar and array parameters.
0 commit comments