Skip to content
Snippets Groups Projects
Commit d6ad9e1d authored by Adriaens, Ines's avatar Adriaens, Ines :v_tone2:
Browse files

explore penalty and statistic

parent 77c2b456
Branches
No related tags found
No related merge requests found
......@@ -147,7 +147,7 @@ for i = 1:10%length(fields_)
seldata.(fields_{i}).avg_z_sm,'Color',[178/255 34/255 34/255],...
'LineWidth',1)
plot(seldata.(fields_{i}).numtime-min(seldata.(fields_{i}).numtime),...
seldata.(fields_{i}).islying*2.3,'Color',[0/255 0/255 128/255],...
seldata.(fields_{i}).islying*(-2.3)+2.3,'Color',[0/255 0/255 128/255],...
'LineWidth',2)
subplot(2,1,2); hold on;box on; title('Center distance',...
'Interpreter','none');
......@@ -156,7 +156,7 @@ for i = 1:10%length(fields_)
seldata.(fields_{i}).centerdist,'Color',[178/255 34/255 34/255],...
'LineWidth',1)
plot(seldata.(fields_{i}).numtime-min(seldata.(fields_{i}).numtime),...
seldata.(fields_{i}).islying*13,'Color',[0/255 0/255 128/255],...
seldata.(fields_{i}).islying*(-13)+13,'Color',[0/255 0/255 128/255],...
'LineWidth',2)
end
......@@ -329,4 +329,38 @@ end
figure('Units','centimeters','OuterPosition',[4 1 28 20]);
subplot(2,3,1); plot(cpsums.nochanges,cpsums.ZmeanDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
\ No newline at end of file
subplot(2,3,2); plot(cpsums.nochanges,cpsums.ZstdDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
subplot(2,3,3); plot(cpsums.nochanges,cpsums.ZrmsDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
subplot(2,3,4); plot(cpsums.nochanges,cpsums.CDmeanDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
subplot(2,3,5); plot(cpsums.nochanges,cpsums.CDstdDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
subplot(2,3,6); plot(cpsums.nochanges,cpsums.CDrmsDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
% try a different approach based on a moving STD window of 30 minutes
tic
ind = find(~isnan(seldata.cow_99.avg_z_sm));
n = length(ind);
x = seldata.cow_99.avg_z_sm(ind);
test = movsum(30*60*log(movvar(x,30*60)),30*60);
toc
figure;
plot(test)
sum(n*log(var(x,1,2)));
[~,b] = findchangepts(x,'Statistic','std','MinThreshold',100000000000)
figure,
findchangepts(x,'Statistic','std','MinThreshold',abs(b)*0.05, 'MinDistance',600)
figure,
findchangepts(x,'Statistic','std','MaxNumChanges',20, 'MinDistance',600)
% for "mean" ==> residue = n*sum(var(x,1,2));
% for "std" ==> residue = sum(n*log(var(x,1,2)));
% for "rms" ==> residue = sum(n*log(sum(x.^2,2)/n));
\ No newline at end of file
......@@ -147,7 +147,7 @@ for i = 1:10%length(fields_)
seldata.(fields_{i}).avg_z_sm,'Color',[178/255 34/255 34/255],...
'LineWidth',1)
plot(seldata.(fields_{i}).numtime-min(seldata.(fields_{i}).numtime),...
seldata.(fields_{i}).islying*2.3,'Color',[0/255 0/255 128/255],...
seldata.(fields_{i}).islying*(-2.3)+2.3,'Color',[0/255 0/255 128/255],...
'LineWidth',2)
subplot(2,1,2); hold on;box on; title('Center distance',...
'Interpreter','none');
......@@ -156,7 +156,7 @@ for i = 1:10%length(fields_)
seldata.(fields_{i}).centerdist,'Color',[178/255 34/255 34/255],...
'LineWidth',1)
plot(seldata.(fields_{i}).numtime-min(seldata.(fields_{i}).numtime),...
seldata.(fields_{i}).islying*13,'Color',[0/255 0/255 128/255],...
seldata.(fields_{i}).islying*(-13)+13,'Color',[0/255 0/255 128/255],...
'LineWidth',2)
end
......@@ -338,4 +338,29 @@ subplot(2,3,4); plot(cpsums.nochanges,cpsums.CDmeanDif,'o','Color',[102/255 0 51
subplot(2,3,5); plot(cpsums.nochanges,cpsums.CDstdDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
subplot(2,3,6); plot(cpsums.nochanges,cpsums.CDrmsDif,'o','Color',[102/255 0 51/255],...
'MarkerSize',6,'LineWidth',1.5)
\ No newline at end of file
'MarkerSize',6,'LineWidth',1.5)
% try a different approach based on a moving STD window of 30 minutes
tic
ind = find(~isnan(seldata.cow_152.avg_z_sm));
n = length(ind);
x = seldata.cow_152.avg_z_sm(ind);
test = movsum(30*60*log(movvar(x,30*60)),30*60);
toc
figure;
plot(test)
sum(n*log(var(x,1,2)));
[~,b] = findchangepts(x,'Statistic','std','MinThreshold',100000000000)
figure,
findchangepts(x,'Statistic','std','MinThreshold',abs(b)*0.05, 'MinDistance',600)
figure,
findchangepts(x,'Statistic','std','MaxNumChanges',20, 'MinDistance',600)
% for "mean" ==> residue = n*sum(var(x,1,2));
% for "std" ==> residue = sum(n*log(var(x,1,2)));
% for "rms" ==> residue = sum(n*log(sum(x.^2,2)/n));
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment