I am currently trying to implement change point detection using this guide: http://nbviewer.jupyter.org/github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb
It uses a switch statement to decide between the parameters of distributions for before and after the change point.
lambda_ = pm.math.switch(tau > idx, lambda_1, lambda_2)
I am also trying to find a changepoint, but using data that is assumed to come from a multivariate distribution.
Here is my code:
tau = pm.Uniform("tau_", lower = x_data, upper = x_data[-1]) mus_1 = pm.Uniform("mus1", lower = min(y_data), upper = max(y_data), shape = 10) mus_2 = pm.Uniform("mus2", lower = min(y_data), upper = max(y_data), shape = 10) mus_ = pm.math.switch(tau > x_data, mus_1, mus_2)
I put shape as 10 for the distribution assumed is a multivariate normal distribution with 10 variables.
I assumed that the switch statement would assign the shape 10 random variable element wise to the x_data (7919 points)
However, I get the following error:
ValueError: Input dimension mis-match. (input.shape = 7919, input.shape = 10)
It seems like the switch statement only allows you to switch between one-dimensional random variables, how do I work around this?