% Exponentially-weighted Minkowski summation temporal pooling method
% omtp = temppool_expminkowski(om, p, tau)
% om vector of objective metric scores for each frame
% p Minkowski exponent
% tau exponential time constant (given as number of frames) controlling the strength of recency effect
% High values of p emphasize the influence of the highest frame scores on
% overall quality. For VQM, MSE and sqrtMSE this means that the most
% distorted frames have the highest influence.
% High values of tau correspond to a weaker recency effect.
function omtp = temppool_expminkowski(om, p, tau)
    if ~isvector(om)
        error('Input om must be a vector')
    end
    if ~isscalar(p) || p <= 0
        error('Input p must be a positive scalar')
    end
    if ~isscalar(tau) || tau <= 0 || tau > length(om)
        error('Input tau must be a positive scalar smaller or equal than length(om)');
    end
    [a,b] = size(om);
    if a > b
        om = om';
    end
    expvec = exp(((1-length(om)):0)./tau);
    omtp = nthroot(1/length(om)*sum(expvec.*(om.^p)), p);