{ "cells": [ { "cell_type": "markdown", "id": "ffd6f22b", "metadata": {}, "source": [ "# Calculating median and quantiles" ] }, { "cell_type": "code", "execution_count": 1, "id": "79fa4319-28ee-4c43-8b59-d56c16fea592", "metadata": {}, "outputs": [], "source": [ "# import core as core\n", "from iosacal import R" ] }, { "cell_type": "markdown", "id": "ea4b9d86-5f26-4e58-a94b-362d1e3db57b", "metadata": {}, "source": [ "This notebook demonstrates how to compute a calibrated median and 68 or 95% confidence interval from a radiocarbon datum.[^download]\n", "[^download]: This notebook can be downloaded as {nb-download}`quantiles_demo.ipynb`" ] }, { "cell_type": "code", "execution_count": 2, "id": "afa25524-97aa-4c88-a4f7-18887c81d535", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Median = 1969.0 \n", " 1σ = [1611.0, 2330.0] \n", " 2σ = [1355.0, 2710.0] \n", "\n", " Median = 3171.0 \n", " 1σ = [2854.0, 3453.0] \n", " 2σ = [2494.0, 3834.0] \n", "\n", " Median = 5155.0 \n", " 1σ = [5052.0, 5287.0] \n", " 2σ = [4976.0, 5312.0] \n", "\n", " Median = 7395.0 \n", " 1σ = [7324.0, 7474.0] \n", " 2σ = [7273.0, 7562.0] \n" ] } ], "source": [ "#example radiocarbon\n", "c14_ages = [2000, 3000, 4500, 6500]\n", "c14_1σ = [300, 260, 50, 70]\n", "\n", "for age, oneσ in zip(c14_ages, c14_1σ):\n", "\n", "\n", " cr = R(age, oneσ, 'test')\n", " cal = cr.calibrate('intcal20')\n", "\n", " quants = cal.quantiles()\n", "\n", " print(f'\\n Median = {quants[50]} \\n 1σ = {quants[68]} \\n 2σ = {quants[95]} ')\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "c85d3b2d-ab3e-4078-b6e8-292afd9d87c8", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }