By Chaow Wu

2018-06-13 14:40:35 8 Comments

I am currently trying to implement change point detection using this guide:

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[0], upper = x_data[-1])
mus_1 = pm.Uniform("mus1", lower = min(y_data[0]), upper = max(y_data[0]), shape = 10)
mus_2 = pm.Uniform("mus2", lower = min(y_data[0]), upper = max(y_data[0]), 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[0].shape[0] = 7919, input[1].shape[0] = 10)

It seems like the switch statement only allows you to switch between one-dimensional random variables, how do I work around this?


Related Questions

Sponsored Content

36 Answered Questions

[SOLVED] How do I check if a list is empty?

  • 2008-09-10 06:20:11
  • Ray Vega
  • 2047613 View
  • 3074 Score
  • 36 Answer
  • Tags:   python list

25 Answered Questions

[SOLVED] How can I safely create a nested directory in Python?

40 Answered Questions

[SOLVED] How do I check whether a file exists without exceptions?

25 Answered Questions

[SOLVED] How do I list all files of a directory?

  • 2010-07-08 19:31:22
  • duhhunjonn
  • 2940584 View
  • 3235 Score
  • 25 Answer
  • Tags:   python directory

24 Answered Questions

[SOLVED] How do I pass a variable by reference?

44 Answered Questions

[SOLVED] How to merge two dictionaries in a single expression?

16 Answered Questions

[SOLVED] How to make a chain of function decorators?

17 Answered Questions

[SOLVED] Are static class variables possible?

41 Answered Questions

[SOLVED] How do I sort a dictionary by value?

18 Answered Questions

[SOLVED] Using global variables in a function

Sponsored Content