function [ combined_life, male_life, female_life ] = mortality_average_life ()

%*****************************************************************************80
%
%% mortality_average_life() estimates the average life span.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 February 2024
%
%  Author:
%
%    John Burkardt
%
%  Output:
%
%    real combined_life, male_life, female life: the average life span for
%    the combined, male, and female populations.
%
  [ age_death, combined_death, male_death, female_death ] = mortality_count ( );

  combined_life = 0.0;
  male_life = 0.0;
  female_life = 0.0;

  age_max = length ( age_death );

  for i = 1 : age_max
    years = age_death(i) + 0.5;
    combined_life = combined_life + years * combined_death(i);
    male_life = male_life + years * male_death(i);
    female_life = female_life + years * female_death(i);
  end

  combined_life = combined_life / sum ( combined_death );
  male_life = male_life / sum ( male_death );
  female_life = female_life / sum ( female_death );

  return
end
