% This function is part of the NMSM Pipeline, see file for full license.
%
% This function calculates the differences in mean between two curves. The
% purpose of this is to be used in a cost function that incentivises the
% optimized curve to closely match the original curve.
%
% (3D array of number, 3D array of number) -> (2D array of number)
% Calculates deviations in mean across trials (dimension 1)
function meanDeviations = calcMeanDeviations(optimizedCurves, ...
originalCurves)
meanOptimizedCurves = mean(mean(optimizedCurves, 1), 3) - ...
mean(originalCurves, "all");
meanOriginalCurves = mean(mean(originalCurves, 1), 3) - ...
mean(originalCurves, "all");
meanDeviations = (meanOptimizedCurves - meanOriginalCurves) - ...
mean(meanOptimizedCurves - meanOriginalCurves);
end