import numpy as np
from changepoint.mean_shift_model import MeanShiftModel 
ts = np.concatenate([np.random.normal(0, 0.1, 10), np.random.normal(1, 0.1, 10)]) 
model = MeanShiftModel() 
stats_ts, pvals, nums = model.detect_mean_shift(ts, B=10000)

%matplotlib inline

import pylab as pl

pl.plot(ts)

pl.plot(stats_ts)

pvals

np.argmin(pvals)

np.where(np.array(stats_ts)>1.0)

"""
Explanation: Time series with change point
End of explanation
"""


import numpy as np
from changepoint.mean_shift_model import MeanShiftModel 
ts = np.concatenate([np.random.normal(0, 0.1, 10), np.random.normal(0, 0.1, 10)]) 
model = MeanShiftModel() 
stats_ts, pvals, nums = model.detect_mean_shift(ts, B=10000)

pl.plot(ts)

pvals

np.where(np.array(pvals)<0.05)

np.where(np.array(stats_ts)>1.0)

"""
Explanation: One strategy to choose a change point is to pick a point which has a low pvalue and also has a large enough effect size. Note that a changepoint depends on 2 things (a) Effect size and (b) Significance (pvalue). It is possible for very small effect sizes to also be significant. That is why we need to use both criterion to ultimately get a estimate. Here I used the threshold for effect size as 1.0 (this depends on your data) and the significance level of 0.05  
Time series with no change point
End of explanation
"""


