-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBOCDm.m
34 lines (28 loc) · 1.33 KB
/
BOCDm.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
%% Bayesian Online Change-point Detection modified without restart and simple prior
% Inputs:
% -- NbrRuns:
% -- environment: vector of piece-wise Bernoulli distributions
% Outputs:
% -- ChangePointEstimations: vector of change-point estimations
function [ChangePointEstimations]= BOCDm(environment, NbrRuns)
% ----------------- Initialization -------------------
Horizon = length(environment);
gamma = (1./Horizon);
ChangePointEstimations = [];
%----------- Launch the Online Change-point Detection procedure
display('Launching BOCD modified ...')
for run = 1:NbrRuns;
ForecasterDistribution = [1];
PseudoDist = [1];
CPEstimation = []; % ChangePoint estimation at each time t
like1 = 1;
alphas = [1];betas = [1]; % Initialization for Laplace predictor
for t = 1: Horizon
[~, BestForecaster] = max(ForecasterDistribution); %Change-point estimation
CPEstimation = [CPEstimation BestForecaster];
x = rand() < environment(t); % Get the observation from the environment
[ForecasterDistribution, PseudoDist,like1] = updateForecasterDistribution_m(ForecasterDistribution, PseudoDist, alphas,betas,x,gamma, like1);
[alphas, betas] = updateLaplacePrediction(alphas,betas, x);
end
ChangePointEstimations = [ChangePointEstimations; CPEstimation];
end