Copyright Tristan Aubrey-Jones April 2007.
function ratios = computeLikelihoodRatios(sample,step)
% COMPUTELIKELIHOODRATIOS computes the likelyhood ratios
% each of the models M in {M1,M2,M3} for subsets of the
% sample in steps of 'step' size and returns them as
% a matrix of rows where each row is like:
%
% row = [M1/M2 M1/M3 M2/M3];
ratios = [];
sz = size(sample);
t = [0; 0; 0];
for i = 1:sz(1)
% compute P of current event occuring
p = probOfEvent(sample(i,1:sz(2)));
% multiply ratios by totals
t = [t(1) + log(p(1));
t(2) + log(p(2));
t(3) + log(p(3))];
% if step add to results
if mod(i,step) == 0
rsz = size(ratios);
ratios(rsz(1)+1, 1:3) = [t(1) - t(2); t(1) - t(3); t(2) - t(3)];
end
end