Skip to content

Instantly share code, notes, and snippets.

@ckrapu
Created February 10, 2023 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckrapu/11c414ca02100e4899b3867918a21242 to your computer and use it in GitHub Desktop.
Save ckrapu/11c414ca02100e4899b3867918a21242 to your computer and use it in GitHub Desktop.
pymc-concatenate-constant
import pymc as pm
import numpy as np
with pm.Model() as model:
x = pm.Normal('x', shape=2)
x_2d = pm.Normal('x_2d', shape=(3,4))
# Takes variable of shape (2,) and extends it to shape (3,)
y = pm.Deterministic('y',pm.math.concatenate([x, [0]], axis=0))
# Takes variable of shape (3,4) and extends it to shape (3,5)
y_2d = pm.Deterministic('y_2d',pm.math.concatenate([x_2d, np.ones([3,1])], axis=1))
trace = pm.sample()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment