package com.imsl.test.example.stat; import com.imsl.stat.*; import com.imsl.math.*; /** *

* Computes a cohort life table. *

* This example is taken from Chiang (1968). The cohort life table has thirteen * equally spaced intervals, so age[0] is set to -5.0. Similarly, the * probabilities of death prior to the middle of the interval are all taken to * be 0.5, so a[0] is set to -1.0. * * * @see Code * @see Output */ public class LifeTablesEx1 { public static void main(String args[]) { int[] nCohort = { 270, 268, 264, 261, 254, 251, 248, 232, 166, 130, 76, 34, 13 }; double[] age = new double[nCohort.length + 1]; double[] a = new double[nCohort.length]; age[0] = -5.0; a[0] = -1.0; LifeTables lt = new LifeTables(nCohort, age, a); double[][] table = lt.getLifeTable(); PrintMatrixFormat pmf = new PrintMatrixFormat(); String[] cols = { "Age", "PDHALF", "Alive", "Deaths", "Death Rate", "P(D)", "Std(P(D))", "P(S)", "Std(P(S))", "Lifetime", "Std(Life)", "Time Units" }; pmf.setColumnLabels(cols); pmf.setNumberFormat(new java.text.DecimalFormat("0.0####")); PrintMatrix pm = new PrintMatrix("Life Table"); pm.setPageWidth(40); pm.print(pmf, table); } }