Commit a98a09b9 authored by Nicolas Rodriguez's avatar Nicolas Rodriguez

Upload New File

parent 9a6e972e
%
% Copyright 2019-2020 LIST (Luxembourg Institute of Science and Technology), all right reserved.
%
% Author: Nicolas Rodriguez (nicolas.bjorn.rodriguez@gmail.com)
%
function [FYW,MA,mA]=weighted_age_metrics(MD,frc,dT,weights)
% MD: master distribution
% MA: mean age
% mA: median age
temp=find(cumsum(MD*dT)<=0.5);
if ~isempty(temp)
mA=temp(end)*dT; % hours
else
mA=NaN;
end
temp=(dT:dT:dT*length(MD)); % vector of ages (hours)
MA=trapz(temp,temp.*MD); % hours
[r,~]=size(frc);
FYW=NaN(r,1);
for k=1:r
FYW(k,1)=sum(frc(k,:).*weights')/sum(weights);
end
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment