{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pymc3 as pm\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from utils import ECDF\n", "from data import load_decay\n", "import pandas as pd\n", "import theano.tensor as tt\n", "import arviz as az\n", "\n", "%load_ext autoreload\n", "%autoreload 2\n", "%matplotlib inline\n", "%config InlineBackend.figure_format = 'retina'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Arbitrary Curve Regression\n", "\n", "Now that you've learned about Bayesian estimation, we're going to explore one more topic: Bayesian curve fitting.\n", "\n", "By \"curve fitting\", we're really talking about any curve: those that are bendy, those that are straight, and those that are in between. \n", "\n", "In order to reinforce this point, rather than show you plain vanilla linear regression, we will work through an exponential decay curve example." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Problem Setup\n", "\n", "You've taken radioactive decay measurements of an unknown element in a secure facility. The measurements are noisy, though, and potentially have some bias. In the face of this, we would like to be able to characterize the decay constant of this unknown material, potentially leading to an identification of the material." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load Data\n", "\n", "Let's load in the data." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | t | \n", "activity | \n", "
---|---|---|
0 | \n", "0 | \n", "63.496714 | \n", "
1 | \n", "1 | \n", "62.281634 | \n", "
2 | \n", "2 | \n", "62.495498 | \n", "
3 | \n", "3 | \n", "62.806653 | \n", "
4 | \n", "4 | \n", "60.493075 | \n", "