Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions pymc/distributions/multivariate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,7 +1792,7 @@ class MatrixNormal(Continuous):
--------
Define a matrixvariate normal variable for given row and column covariance
matrices::

with pm.Model() as model:
Copy link
Member

@ricardoV94 ricardoV94 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a .. code:: python with white line above and below to render nicely

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also include imports so example is fully specified

Copy link
Contributor Author

@roesta07 roesta07 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • added imports on top.
  • added codeblocks .. code:: python with appropriate whitespaces
    Check these recent changes

colcov = np.array([[1.0, 0.5], [0.5, 2]])
rowcov = np.array([[1, 0, 0], [0, 4, 0], [0, 0, 16]])
m = rowcov.shape[0]
Expand Down Expand Up @@ -1827,16 +1827,13 @@ class MatrixNormal(Continuous):
with pm.Model() as model:
# Setup right cholesky matrix
sd_dist = pm.HalfCauchy.dist(beta=2.5, shape=3)
colchol_packed = pm.LKJCholeskyCov('colcholpacked', n=3, eta=2,
sd_dist=sd_dist)
colchol = pm.expand_packed_triangular(3, colchol_packed)

colchol,_,_ = pm.LKJCholeskyCov('colchol', n=3, eta=2,sd_dist=sd_dist)
# Setup left covariance matrix
scale = pm.LogNormal('scale', mu=np.log(true_scale), sigma=0.5)
rowcov = pt.diag([scale**(2*i) for i in range(m)])

vals = pm.MatrixNormal('vals', mu=mu, colchol=colchol, rowcov=rowcov,
Copy link
Member

@ricardoV94 ricardoV94 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suggestion can't be applied directyl, but this seems more clean

Suggested change
vals = pm.MatrixNormal('vals', mu=mu, colchol=colchol, rowcov=rowcov,
vals = pm.MatrixNormal('vals', mu=mu, colchol=colchol, rowcov=rowcov, observed=data)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missid this. I would put in same line, looks odd split

observed=data)
observed=data)
"""

rv_op = matrixnormal
Expand Down
Loading