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

41 Answered Questions

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

25 Answered Questions

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

49 Answered Questions

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

32 Answered Questions

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

  • 2010-07-08 19:31:22
  • duhhunjonn
  • 2565849 View
  • 2922 Score
  • 32 Answer
  • Tags:   python directory

39 Answered Questions

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

  • 2008-09-17 12:55:00
  • spence91
  • 3028199 View
  • 4470 Score
  • 39 Answer
  • Tags:   python file

27 Answered Questions

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

  • 2008-09-10 06:20:11
  • Ray Vega
  • 1811427 View
  • 2809 Score
  • 27 Answer
  • Tags:   python list is-empty

18 Answered Questions

[SOLVED] Using global variables in a function

15 Answered Questions

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

23 Answered Questions

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

16 Answered Questions

[SOLVED] Are static class variables possible?

Sponsored Content