function p_death = die_this_year ( age, sex )

%*****************************************************************************80
%
%% die_this_year() returns probability a given judge will die within one year.
%
%  Licensing, 
%
%    This code is distributed under the MIT license.
%
%  Modified, 
%
%    22 January 2025
%
%  Author, 
%
%    John Burkardt
%
%  Input, 
%
%    integer age,  the age of the judge at the beginning of a year.
%
%    string sex,  the sex of the judge, 'M' or 'F'.
%
%  Output, 
%
%    real p_death,  the probability that this judge will die before
%    reaching age+1.
%
  table = [ ...
    0,   1,   0.0120,    0.0135,    0.0105; ...
    1,   2,   0.0008,    0.0009,    0.0007; ...
    2,   3,   0.0005,    0.0006,    0.0004; ...
    3,   4,   0.0004,    0.0004,    0.0003; ...
    4,   5,   0.0003,    0.0003,    0.0002; ...
    5,   6,   0.0002,    0.0003,    0.0002; ...
    6,   7,   0.0002,    0.0003,    0.0002; ...
    7,   8,   0.0002,    0.0003,    0.0002; ...
    8,   9,   0.0002,    0.0002,    0.0002; ...
    9,  10,   0.0002,    0.0002,    0.0002; ...
   10,  11,   0.0002,    0.0003,    0.0002; ...
   11,  12,   0.0002,    0.0003,    0.0002; ...
   12,  13,   0.0002,    0.0003,    0.0002; ...
   13,  14,   0.0003,    0.0004,    0.0003; ...
   14,  15,   0.0004,    0.0005,    0.0003; ...
   15,  16,   0.0006,    0.0008,    0.0004; ...
   16,  17,   0.0008,    0.0011,    0.0006; ...
   17,  18,   0.0011,    0.0016,    0.0006; ...
   18,  19,   0.0015,    0.0022,    0.0008; ...
   19,  20,   0.0016,    0.0025,    0.0008; ...
   20,  21,   0.0016,    0.0024,    0.0008; ...
   21,  22,   0.0018,    0.0027,    0.0008; ...
   22,  23,   0.0018,    0.0029,    0.0008; ...
   23,  24,   0.0017,    0.0027,    0.0008; ...
   24,  25,   0.0018,    0.0028,    0.0009; ...
   25,  26,   0.0018,    0.0027,    0.0009; ...
   26,  27,   0.0018,    0.0027,    0.0010; ...
   27,  28,   0.0018,    0.0027,    0.0010; ...
   28,  29,   0.0018,    0.0026,    0.0010; ...
   29,  30,   0.0018,    0.0026,    0.0011; ...
   30,  31,   0.0018,    0.0025,    0.0010; ...
   31,  32,   0.0018,    0.0025,    0.0011; ...
   32,  33,   0.0018,    0.0025,    0.0012; ...
   33,  34,   0.0019,    0.0026,    0.0012; ...
   34,  35,   0.0021,    0.0028,    0.0014; ...
   35,  36,   0.0023,    0.0030,    0.0016; ...
   36,  37,   0.0025,    0.0034,    0.0017; ...
   37,  38,   0.0027,    0.0036,    0.0019; ...
   38,  39,   0.0029,    0.0038,    0.0021; ...
   39,  40,   0.0030,    0.0039,    0.0022; ...
   40,  41,   0.0033,    0.0043,    0.0025; ...
   41,  42,   0.0037,    0.0048,    0.0027; ...
   42,  43,   0.0042,    0.0055,    0.0030; ...
   43,  44,   0.0049,    0.0062,    0.0036; ...
   44,  45,   0.0054,    0.0070,    0.0040; ...
   45,  46,   0.0059,    0.0076,    0.0043; ...
   46,  47,   0.0065,    0.0084,    0.0048; ...
   47,  48,   0.0071,    0.0090,    0.0054; ...
   48,  49,   0.0076,    0.0097,    0.0057; ...
   49,  50,   0.0082,    0.0107,    0.0060; ...
   50,  51,   0.0090,    0.0116,    0.0066; ...
   51,  52,   0.0097,    0.0125,    0.0071; ...
   52,  53,   0.0101,    0.0133,    0.0073; ...
   53,  54,   0.0108,    0.0143,    0.0075; ...
   54,  55,   0.0112,    0.0147,    0.0081; ...
   55,  56,   0.0119,    0.0158,    0.0084; ...
   56,  57,   0.0124,    0.0164,    0.0088; ...
   57,  58,   0.0132,    0.0175,    0.0094; ...
   58,  59,   0.0140,    0.0184,    0.0101; ...
   59,  60,   0.0152,    0.0198,    0.0112; ...
   60,  61,   0.0168,    0.0219,    0.0124; ...
   61,  62,   0.0146,    0.0191,    0.0108; ...
   62,  63,   0.0156,    0.0202,    0.0117; ...
   63,  64,   0.0174,    0.0227,    0.0129; ...
   64,  65,   0.0194,    0.0254,    0.0145; ...
   65,  66,   0.0193,    0.0249,    0.0146; ...
   66,  67,   0.0195,    0.0253,    0.0148; ...
   67,  68,   0.0203,    0.0262,    0.0156; ...
   68,  69,   0.0215,    0.0279,    0.0165; ...
   69,  70,   0.0234,    0.0302,    0.0180; ...
   70,  71,   0.0243,    0.0313,    0.0188; ...
   71,  72,   0.0264,    0.0341,    0.0205; ...
   72,  73,   0.0290,    0.0371,    0.0230; ...
   73,  74,   0.0304,    0.0392,    0.0239; ...
   74,  75,   0.0334,    0.0428,    0.0266; ...
   75,  76,   0.0374,    0.0478,    0.0299; ...
   76,  77,   0.0413,    0.0528,    0.0333; ...
   77,  78,   0.0462,    0.0590,    0.0374; ...
   78,  79,   0.0504,    0.0641,    0.0412; ...
   79,  80,   0.0567,    0.0719,    0.0467; ...
   80,  81,   0.0629,    0.0802,    0.0519; ...
   81,  82,   0.0699,    0.0883,    0.0585; ...
   82,  83,   0.0788,    0.0982,    0.0672; ...
   83,  84,   0.0872,    0.1088,    0.0747; ...
   84,  85,   0.0961,    0.1208,    0.0823; ...
   85,  86,   0.1091,    0.1362,    0.0945; ...
   86,  87,   0.1212,    0.1511,    0.1060; ...
   87,  88,   0.1307,    0.1626,    0.1151; ...
   88,  89,   0.1379,    0.1694,    0.1234; ...
   89,  90,   0.1537,    0.1905,    0.1377; ...
   90,  91,   0.1663,    0.2045,    0.1507; ...
   91,  92,   0.1829,    0.2217,    0.1680; ...
   92,  93,   0.2019,    0.2434,    0.1871; ...
   93,  94,   0.2203,    0.2656,    0.2052; ...
   94,  95,   0.2397,    0.2850,    0.2258; ...
   95,  96,   0.2590,    0.3100,    0.2446; ...
   96,  97,   0.2707,    0.3122,    0.2599; ...
   97,  98,   0.2954,    0.3394,    0.2848; ...
   98,  99,   0.3156,    0.3549,    0.3069; ...
   99, 100,   0.3361,    0.3793,    0.3272; ...
  100, 101,   0.3518,    0.3744,    0.3474; ...
  101, 102,   0.3800,    0.4166,    0.3732; ...
  102, 103,   0.3909,    0.4180,    0.3862; ...
  103, 104,   0.4123,    0.4065,    0.4132; ...
  104, 105,   0.4297,    0.4900,    0.4198; ...
  105, 106,   0.4605,    0.4216,    0.4661; ...
  106, 107,   0.4697,    0.5678,    0.4544; ...
  107, 108,   0.4892,    0.3725,    0.5036; ...
  108, 109,   0.4810,    0.4688,    0.4829; ...
  109, 110,   0.5122,    0.4706,    0.5189; ...
  110, 111,   0.4833,    0.5556,    0.4706; ...
  111, 112,   0.5484,    0.5000,    0.5556; ...
  112, 113,   0.6429,    1.0000,    0.5833; ...
  113, 114,   0.8000,    1.0000,    0.8000; ...
  114, 115,   1.0000,    1.0000,    1.0000 ];

  if ( age < 0 )
    p_death = 0.0;
  elseif ( 114 < age )
    p_death = 1.0;
  elseif ( sex == 'M' )
    p_death = table(age+1,4);
  else
    p_death = table(age+1,5);
  end

  return
end

