.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/time_value/annuities/plot_01_de_witt_life_annuity.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_time_value_annuities_plot_01_de_witt_life_annuity.py: De Witt's life annuities ======================== In 1671 Johan de Witt, Grand Pensionary of Holland, sent the States General his *Waerdye van Lyf-renten*, arguing that the life annuities the province sold at 14 years' purchase were too cheap. He valued an annuity as the sum of each payment, discounted at 4% and weighted by the chance that the buyer is still alive to receive it, under a simple mortality hypothesis: an equal chance of death in every half-year up to age 53, rising to 1.5, 2 and 3 times that in the bands 53-63, 63-73 and 73-80. .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from financialkit.time_value import annuity_factor, de_witt_survival, life_annuity_value .. GENERATED FROM PYTHON SOURCE LINES 21-24 Survival and the value of a life annuity ---------------------------------------- Annual payments of 1 florin, discounted at 4%. .. GENERATED FROM PYTHON SOURCE LINES 24-32 .. code-block:: Python ages = [3, 20, 40, 60, 70] k = np.arange(1, 78) for age in ages: p = de_witt_survival(age, k, base_hazard=0.015) print(f"age {age:2d}: life annuity worth {life_annuity_value(1.0, 0.04, p):5.2f} years' purchase") print(f"perpetual annuity-certain at 4%: {annuity_factor(0.04, 10_000):.2f}") .. rst-class:: sphx-glr-script-out .. code-block:: none age 3: life annuity worth 17.57 years' purchase age 20: life annuity worth 16.99 years' purchase age 40: life annuity worth 15.11 years' purchase age 60: life annuity worth 10.32 years' purchase age 70: life annuity worth 6.28 years' purchase perpetual annuity-certain at 4%: 25.00 .. GENERATED FROM PYTHON SOURCE LINES 33-35 The ingredients --------------- .. GENERATED FROM PYTHON SOURCE LINES 35-56 .. code-block:: Python fig, axes = plt.subplots(1, 2, figsize=(11, 4)) t = np.linspace(0.0, 77.0, 400) for age in ages: axes[0].plot(age + t, de_witt_survival(age, t, base_hazard=0.015), label=f"bought at {age}") axes[0].set_xlabel("age") axes[0].set_ylabel("probability alive") axes[0].set_title("De Witt's survival curves") axes[0].legend() buy_ages = np.arange(3, 79) values = [life_annuity_value(1.0, 0.04, de_witt_survival(a, k, base_hazard=0.015)) for a in buy_ages] axes[1].plot(buy_ages, values) axes[1].axhline(14.0, color="gray", ls="--", label="price charged: 14 years' purchase") axes[1].set_xlabel("age of annuitant") axes[1].set_ylabel("value of 1 a year for life") axes[1].set_title("Value of a life annuity at 4%") axes[1].legend() fig.tight_layout() plt.show() .. image-sg:: /api/gallery/time_value/annuities/images/sphx_glr_plot_01_de_witt_life_annuity_001.png :alt: De Witt's survival curves, Value of a life annuity at 4% :srcset: /api/gallery/time_value/annuities/images/sphx_glr_plot_01_de_witt_life_annuity_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.083 seconds) .. _sphx_glr_download_api_gallery_time_value_annuities_plot_01_de_witt_life_annuity.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/time_value/annuities/plot_01_de_witt_life_annuity.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_de_witt_life_annuity.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_de_witt_life_annuity.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_de_witt_life_annuity.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_