hildensia / bayesian_changepoint_detection

Methods to get the probability of a changepoint in a time series.
MIT License
670 stars 213 forks source link

Confused about the R matrix interpretation #18

Open RanaElnaggar opened 5 years ago

RanaElnaggar commented 5 years ago

Hi,

I am confused about the returned R matrix interpretation in the online detection algorithm. In the notebook example, the third plot is R[Nw,Nw:-1], where it is mentioned to be "the probability at each time step for a sequence length of 0, i.e. the probability of the current time step to be a changepoint." So why do we choose the indices R[Nw,Nw:-1] ? why not R[Nw,:]

Also, it was mentioned as an example that R[7,3] means the probability at time step 7 taking a sequence of length 3, so does R[Nw,Nw:-1] means that we are taking all the probabilities at time step Nw ?

Any suggestions to help me to understand the output R ?

Thanks

mike-ocean commented 5 years ago

Same question. Confunsed about R[Nw,Nw:-1], and it dose not work in my code...

hildensia commented 5 years ago

To be honest: I'm confused as well. I think I mixed the order of dimensions in the description. So R[7, 3] means the probability at timestep 3 that the sequence is 7 timesteps long (which is not a very sensible question to ask, but just to keep the example the same. Now R[Nw, Nw:-1] means give me the probability for each time step that the sequence is Nw steps long already.

RanaElnaggar commented 5 years ago

Hi,

Thanks for the clarification. Can you also elaborate more on your choice of Nw=10 ? Also, I am confused about how the following statement is related to the original algorithm: "Because it's very hard to correctly evaluate a change after a single sample of a new distribution, we instead can "wait" for Nw samples and evaluate the probability of a change happening Nw samples prior."

Thanks

kmsravindra commented 4 years ago

I think a better way to check for changepoints is by adding a condition something like the below -

thresh = 100
if (abs(maxes[i] - maxes[i+1]) > thresh):
 print("possible changepoint!")

I think this would ensure that the changepoint jump is always greater than a desired threshold whenever it occurs. For more intuitive understanding of BOCD, I have written a blog here that could possibly help to understand.