{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 0
   },
   "source": [
    "# Statistics\n",
    ":label:`sec_statistics`\n",
    "\n",
    "Undoubtedly, to be a top deep learning practitioner, the ability to train the state-of-the-art and high accurate models is crucial.  However, it is often unclear when improvements are significant, or only the result of random fluctuations in the training process.  To be able to discuss uncertainty in estimated values, we must learn some statistics.\n",
    "\n",
    "\n",
    "The earliest reference of *statistics* can be traced back to an Arab scholar Al-Kindi in the $9^{\\mathrm{th}}$-century, who gave a detailed description of how to use statistics and frequency analysis to decipher encrypted messages. After 800 years, the modern statistics arose from Germany in 1700s, when the researchers focused on the demographic and economic data collection and analysis. Today, statistics is the science subject that concerns the collection, processing, analysis, interpretation and visualization of data. What is more, the core theory of statistics has been widely used in the research within academia, industry, and government.\n",
    "\n",
    "\n",
    "More specifically, statistics can be divided to *descriptive statistics* and *statistical inference*. The former focus on summarizing and illustrating the features of a collection of observed data, which is referred to as a *sample*. The sample is drawn from a *population*, denotes the total set of similar individuals, items, or events of our experiment interests. Contrary to descriptive statistics, *statistical inference* further deduces the characteristics of a population from the given *samples*, based on the assumptions that the sample distribution can replicate the population distribution at some degree.\n",
    "\n",
    "\n",
    "You may wonder: “What is the essential difference between machine learning and statistics?” Fundamentally speaking, statistics focuses on the inference problem. This type of problems includes modeling the relationship between the variables, such as causal inference, and testing the statistically significance of model parameters, such as A/B testing. In contrast, machine learning emphasizes on making accurate predictions, without explicitly programming and understanding each parameter's functionality.\n",
    "\n",
    "\n",
    "In this section, we will introduce three types of statistics inference methods: evaluating and comparing estimators, conducting hypothesis tests, and constructing confidence intervals. These methods can help us infer the characteristics of a given population, i.e., the true parameter $\\theta$. For brevity, we assume that the true parameter $\\theta$ of a given population is a scalar value. It is straightforward to extend to the case where $\\theta$ is a vector or a tensor, thus we omit it in our discussion.\n",
    "\n",
    "\n",
    "\n",
    "## Evaluating and Comparing Estimators\n",
    "\n",
    "In statistics, an *estimator* is a function of given samples used to estimate the true parameter $\\theta$. We will write $\\hat{\\theta}_n = \\hat{f}(x_1, \\ldots, x_n)$ for the estimate of $\\theta$ after observing the samples {$x_1, x_2, \\ldots, x_n$}.\n",
    "\n",
    "We have seen simple examples of estimators before in section :numref:`sec_maximum_likelihood`.  If you have a number of samples from a Bernoulli random variable, then the maximum likelihood estimate for the probability the random variable is one can be obtained by counting the number of ones observed and dividing by the total number of samples.  Similarly, an exercise asked you to show that the maximum likelihood estimate of the mean of a Gaussian given a number of samples is given by the average value of all the samples.  These estimators will almost never give the true value of the parameter, but ideally for a large number of samples the estimate will be close.\n",
    "\n",
    "As an example, we show below the true density of a Gaussian random variable with mean zero and variance one, along with a collection samples from that Gaussian.  We constructed the $y$ coordinate so every point is visible and the relationship to the original density is clearer.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "origin_pos": 3,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       "  \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"246.28125pt\" height=\"195.774375pt\" viewBox=\"0 0 246.28125 195.774375\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n",
       " <metadata>\n",
       "  <rdf:RDF xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:cc=\"http://creativecommons.org/ns#\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n",
       "   <cc:Work>\n",
       "    <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\"/>\n",
       "    <dc:date>2022-03-24T13:12:10.285246</dc:date>\n",
       "    <dc:format>image/svg+xml</dc:format>\n",
       "    <dc:creator>\n",
       "     <cc:Agent>\n",
       "      <dc:title>Matplotlib v3.5.1, https://matplotlib.org/</dc:title>\n",
       "     </cc:Agent>\n",
       "    </dc:creator>\n",
       "   </cc:Work>\n",
       "  </rdf:RDF>\n",
       " </metadata>\n",
       " <defs>\n",
       "  <style type=\"text/css\">*{stroke-linejoin: round; stroke-linecap: butt}</style>\n",
       " </defs>\n",
       " <g id=\"figure_1\">\n",
       "  <g id=\"patch_1\">\n",
       "   <path d=\"M 0 195.774375 \n",
       "L 246.28125 195.774375 \n",
       "L 246.28125 0 \n",
       "L 0 0 \n",
       "L 0 195.774375 \n",
       "z\n",
       "\" style=\"fill: none\"/>\n",
       "  </g>\n",
       "  <g id=\"axes_1\">\n",
       "   <g id=\"patch_2\">\n",
       "    <path d=\"M 43.78125 158.218125 \n",
       "L 239.08125 158.218125 \n",
       "L 239.08125 22.318125 \n",
       "L 43.78125 22.318125 \n",
       "z\n",
       "\" style=\"fill: #ffffff\"/>\n",
       "   </g>\n",
       "   <g id=\"PathCollection_1\">\n",
       "    <defs>\n",
       "     <path id=\"m631f6c4206\" d=\"M 0 3 \n",
       "C 0.795609 3 1.55874 2.683901 2.12132 2.12132 \n",
       "C 2.683901 1.55874 3 0.795609 3 0 \n",
       "C 3 -0.795609 2.683901 -1.55874 2.12132 -2.12132 \n",
       "C 1.55874 -2.683901 0.795609 -3 0 -3 \n",
       "C -0.795609 -3 -1.55874 -2.683901 -2.12132 -2.12132 \n",
       "C -2.683901 -1.55874 -3 -0.795609 -3 0 \n",
       "C -3 0.795609 -2.683901 1.55874 -2.12132 2.12132 \n",
       "C -1.55874 2.683901 -0.795609 3 0 3 \n",
       "z\n",
       "\" style=\"stroke: #1f77b4\"/>\n",
       "    </defs>\n",
       "    <g clip-path=\"url(#pc76972f4af)\">\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"145.529851\" y=\"153.36418\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"195.652333\" y=\"153.36418\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"123.01647\" y=\"153.36418\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"160.640266\" y=\"153.364147\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"79.62533\" y=\"153.36418\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"132.150251\" y=\"153.306384\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"123.663074\" y=\"149.18727\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"153.972762\" y=\"152.832668\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"169.660002\" y=\"153.300358\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"185.03079\" y=\"153.351476\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"119.321538\" y=\"149.717559\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"131.665459\" y=\"149.005302\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"111.864824\" y=\"153.114431\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"177.506557\" y=\"152.960559\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"134.655194\" y=\"147.696301\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"126.526786\" y=\"146.099535\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"153.26987\" y=\"148.858422\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"165.006545\" y=\"150.418676\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"151.936914\" y=\"145.609158\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"142.512412\" y=\"150.495649\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"89.554176\" y=\"153.337836\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"211.157439\" y=\"153.364162\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"125.505361\" y=\"141.229316\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"144.886666\" y=\"145.655572\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"230.225938\" y=\"153.36418\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"171.176419\" y=\"148.53036\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"165.536098\" y=\"145.486264\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"181.318646\" y=\"149.314381\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"186.342928\" y=\"148.291448\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"98.125306\" y=\"153.268231\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"163.729348\" y=\"142.491572\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"101.775822\" y=\"151.240355\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"151.905877\" y=\"141.097416\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"90.491882\" y=\"149.161102\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"168.371911\" y=\"140.054261\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"162.327721\" y=\"139.487963\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"135.895623\" y=\"145.227025\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"147.688878\" y=\"141.54454\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"169.502075\" y=\"137.094797\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"140.227977\" y=\"144.910229\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"156.116376\" y=\"141.471357\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"150.6125\" y=\"134.88631\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"81.838509\" y=\"149.842847\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"116.697118\" y=\"148.200642\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"130.908921\" y=\"139.30214\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"122.559793\" y=\"137.447174\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"153.834905\" y=\"131.266334\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"130.100681\" y=\"135.499865\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"188.560616\" y=\"147.331795\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"76.932614\" y=\"149.285013\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"137.104884\" y=\"139.663394\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"75.673325\" y=\"147.069681\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"126.379975\" y=\"132.288334\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"151.023523\" y=\"127.511984\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"169.475482\" y=\"132.88436\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"157.674047\" y=\"136.729949\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"121.467185\" y=\"133.613714\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"155.880776\" y=\"127.758426\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"114.375567\" y=\"145.411179\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"115.153638\" y=\"140.461528\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"162.431989\" y=\"132.076321\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"146.639081\" y=\"133.19675\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"154.709745\" y=\"120.122513\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"148.217342\" y=\"125.830137\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"65.780377\" y=\"153.329621\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"100.866601\" y=\"146.513968\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"130.574405\" y=\"128.894027\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"109.017514\" y=\"148.41479\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"187.348645\" y=\"141.601182\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"151.018469\" y=\"115.285338\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"137.498735\" y=\"135.606478\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"109.21309\" y=\"143.94458\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"94.901272\" y=\"147.393331\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"120.188661\" y=\"131.041086\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"179.655565\" y=\"144.66086\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"116.716012\" y=\"132.476622\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"117.683852\" y=\"127.305647\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"145.631294\" y=\"126.490247\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"135.8867\" y=\"128.991817\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"104.854204\" y=\"144.857281\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"146.754906\" y=\"119.364109\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"132.819663\" y=\"122.591056\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"162.891207\" y=\"127.332218\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"111.939145\" y=\"134.015547\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"145.120767\" y=\"120.097854\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"120.140634\" y=\"121.504328\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"141.24959\" y=\"129.241832\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"165.690243\" y=\"123.250877\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"112.685278\" y=\"128.321019\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"175.223886\" y=\"143.348345\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"93.018469\" y=\"143.290213\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"124.134757\" y=\"120.591948\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"95.609265\" y=\"139.983967\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"115.185494\" y=\"120.442053\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"137.397844\" y=\"123.858967\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"193.226241\" y=\"147.71984\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"148.301199\" y=\"109.238552\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"166.070096\" y=\"119.325091\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"140.442814\" y=\"123.30242\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"125.246855\" y=\"118.292681\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"163.71613\" y=\"116.183723\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"145.599714\" y=\"108.751872\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"157.853773\" y=\"122.971826\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"196.634691\" y=\"146.892653\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"191.495328\" y=\"141.038595\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"177.628519\" y=\"139.307736\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"137.56085\" y=\"117.091801\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"162.460365\" y=\"113.75982\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"144.866322\" y=\"106.36519\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"132.488505\" y=\"115.487287\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"137.63827\" y=\"111.639305\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"163.57668\" y=\"107.596079\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"104.917846\" y=\"140.113604\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"72.542067\" y=\"148.538298\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"160.753509\" y=\"111.71422\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"184.359786\" y=\"136.435476\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"161.192843\" y=\"105.974208\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"103.394271\" y=\"136.176482\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"128.046476\" y=\"117.121208\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"163.671055\" y=\"97.622206\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"120.454345\" y=\"112.543357\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"152.86249\" y=\"105.210013\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"129.721327\" y=\"112.080314\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"82.823895\" y=\"145.290136\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"123.08735\" y=\"107.128074\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"112.836374\" y=\"120.296995\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"80.13103\" y=\"138.565246\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"109.221165\" y=\"127.614541\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"146.295117\" y=\"98.791072\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"110.837211\" y=\"118.747435\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"141.813926\" y=\"108.702987\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"136.990705\" y=\"105.210965\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"179.528224\" y=\"134.272484\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"136.934721\" y=\"101.032103\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"71.798663\" y=\"145.341384\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"123.675578\" y=\"103.196983\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"156.461291\" y=\"108.930866\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"112.726029\" y=\"110.735948\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"113.914467\" y=\"105.949446\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"174.199726\" y=\"134.66252\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"152.1666\" y=\"97.895149\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"79.13559\" y=\"134.143119\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"136.723358\" y=\"96.838189\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"145.44623\" y=\"93.449505\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"133.471406\" y=\"98.64328\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"158.157022\" y=\"105.124455\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"65.078462\" y=\"148.641867\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"114.722789\" y=\"102.210968\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"169.606189\" y=\"119.215068\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"115.564838\" y=\"99.155832\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"134.74906\" y=\"91.509103\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"143.737444\" y=\"93.949333\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"131.034608\" y=\"99.041375\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"149.187925\" y=\"89.820988\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"152.78361\" y=\"90.877607\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"134.023371\" y=\"86.367253\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"199.547241\" y=\"148.062799\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"128.817729\" y=\"100.087445\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"96.671812\" y=\"135.714747\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"128.039389\" y=\"97.517385\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"85.062859\" y=\"142.126894\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"135.143897\" y=\"80.123192\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"116.686102\" y=\"97.195137\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"102.733693\" y=\"130.878085\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"83.024851\" y=\"133.42232\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"128.321019\" y=\"92.486536\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"101.731093\" y=\"127.43682\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"120.476226\" y=\"97.53433\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"146.168928\" y=\"82.212886\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"124.997449\" y=\"91.418372\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"159.219777\" y=\"99.262678\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"180.27267\" y=\"129.584564\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"152.864722\" y=\"85.916393\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"120.765734\" y=\"91.55428\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"149.76418\" y=\"79.284274\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"170.76701\" y=\"119.842601\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"71.423993\" y=\"141.029769\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"146.124388\" y=\"75.587036\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"113.579678\" y=\"91.334129\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"116.506612\" y=\"86.380354\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"147.434783\" y=\"70.254079\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"143.829387\" y=\"79.160838\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"160.231235\" y=\"92.870718\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"134.522577\" y=\"75.396624\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"137.777798\" y=\"79.703763\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"177.083854\" y=\"126.028261\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"76.858618\" y=\"130.731833\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"169.777633\" y=\"111.495445\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"127.981836\" y=\"85.354499\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"126.564713\" y=\"82.29052\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"79.422751\" y=\"123.895848\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"161.273804\" y=\"86.696263\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"131.603881\" y=\"73.39273\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"143.062375\" y=\"78.81042\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"169.732956\" y=\"107.062277\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"171.207329\" y=\"109.198851\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"126.768011\" y=\"76.774082\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"132.611494\" y=\"66.645967\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"159.304472\" y=\"87.000279\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"157.12312\" y=\"85.982241\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"170.158594\" y=\"100.633117\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"140.188471\" y=\"82.304219\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"111.158027\" y=\"98.385617\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"162.448124\" y=\"77.776677\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"134.232766\" y=\"60.917144\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"132.076923\" y=\"59.827536\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"88.797559\" y=\"138.813395\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"125.518895\" y=\"73.427188\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"125.6634\" y=\"68.953167\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"80.501564\" y=\"120.099941\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"88.747589\" y=\"134.544346\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"193.106047\" y=\"137.058201\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"148.078161\" y=\"63.554377\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"104.818569\" y=\"122.98518\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"162.903179\" y=\"74.419196\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"155.518148\" y=\"79.752302\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"135.931316\" y=\"57.40668\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"153.577444\" y=\"72.369696\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"113.782167\" y=\"80.807303\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"94.041613\" y=\"130.378028\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"145.553718\" y=\"58.594272\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"113.154674\" y=\"78.620516\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"121.776105\" y=\"77.740801\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"156.056686\" y=\"73.097595\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"173.586423\" y=\"113.563559\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"66.205672\" y=\"142.881091\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"126.047942\" y=\"62.376038\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"99.706413\" y=\"124.166643\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"144.229672\" y=\"60.335736\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"108.596933\" y=\"108.190948\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"162.046445\" y=\"67.982391\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"180.960498\" y=\"123.763143\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"127.536919\" y=\"57.43431\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"109.478237\" y=\"97.690759\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"168.365703\" y=\"88.820687\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"118.920741\" y=\"78.795294\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"77.845714\" y=\"118.560524\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"196.039725\" y=\"135.67802\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"113.588739\" y=\"69.014985\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"112.263453\" y=\"69.954709\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"80.04705\" y=\"112.302652\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"149.826851\" y=\"59.181128\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"152.732695\" y=\"61.294722\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"119.158893\" y=\"73.350482\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"177.802686\" y=\"116.229012\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"131.954536\" y=\"50.830847\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"146.3807\" y=\"46.887443\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"163.038224\" y=\"65.001265\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"107.030451\" y=\"107.430555\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"163.688543\" y=\"63.128787\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"149.817275\" y=\"50.030124\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"135.463654\" y=\"49.100279\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"85.012294\" y=\"126.471356\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"117.202604\" y=\"66.038281\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"134.792247\" y=\"42.931473\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"207.849786\" y=\"150.858348\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"199.169877\" y=\"139.901447\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"118.399602\" y=\"64.705598\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"103.772809\" y=\"112.313067\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"110.526625\" y=\"75.843669\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"158.326156\" y=\"65.151915\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"154.729595\" y=\"58.14261\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"107.177621\" y=\"97.829926\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"111.861536\" y=\"60.0477\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"117.271424\" y=\"56.813724\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"98.836721\" y=\"119.92374\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"113.442465\" y=\"47.921717\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"126.820463\" y=\"51.694452\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"121.631085\" y=\"58.99184\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"179.327937\" y=\"113.359831\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"154.930756\" y=\"54.490777\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"216.203872\" y=\"152.122899\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"164.176976\" y=\"60.437675\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"116.23438\" y=\"45.856359\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"186.253298\" y=\"128.585509\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"188.945114\" y=\"128.583979\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"147.417231\" y=\"39.545494\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"149.817871\" y=\"40.379165\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"52.658523\" y=\"153.361733\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"167.498544\" y=\"76.638968\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"88.861505\" y=\"127.235417\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"133.738308\" y=\"37.620358\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"141.720079\" y=\"66.950253\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"105.386245\" y=\"100.021853\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"177.15111\" y=\"108.634784\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"127.510022\" y=\"45.684823\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"77.464419\" y=\"112.311015\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"152.705231\" y=\"42.674658\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"155.744812\" y=\"48.976522\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"135.318066\" y=\"35.85105\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"90.31311\" y=\"123.191109\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"115.799523\" y=\"40.499601\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"150.989452\" y=\"34.036574\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"121.350998\" y=\"52.515605\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"124.759\" y=\"43.701451\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"114.440606\" y=\"34.772187\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"113.880573\" y=\"31.783543\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"136.495993\" y=\"38.623382\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"85.270731\" y=\"119.61296\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "     <use xlink:href=\"#m631f6c4206\" x=\"140.464179\" y=\"62.555848\" style=\"fill: #1f77b4; stroke: #1f77b4\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_1\">\n",
       "    <g id=\"xtick_1\">\n",
       "     <g id=\"line2d_1\">\n",
       "      <path d=\"M 73.69966 158.218125 \n",
       "L 73.69966 22.318125 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_2\">\n",
       "      <defs>\n",
       "       <path id=\"m3f3480c4d5\" d=\"M 0 0 \n",
       "L 0 3.5 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3f3480c4d5\" x=\"73.69966\" y=\"158.218125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_1\">\n",
       "      <!-- −2 -->\n",
       "      <g transform=\"translate(66.328566 172.816562)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2212\" d=\"M 678 2272 \n",
       "L 4684 2272 \n",
       "L 4684 1741 \n",
       "L 678 1741 \n",
       "L 678 2272 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "        <path id=\"DejaVuSans-32\" d=\"M 1228 531 \n",
       "L 3431 531 \n",
       "L 3431 0 \n",
       "L 469 0 \n",
       "L 469 531 \n",
       "Q 828 903 1448 1529 \n",
       "Q 2069 2156 2228 2338 \n",
       "Q 2531 2678 2651 2914 \n",
       "Q 2772 3150 2772 3378 \n",
       "Q 2772 3750 2511 3984 \n",
       "Q 2250 4219 1831 4219 \n",
       "Q 1534 4219 1204 4116 \n",
       "Q 875 4013 500 3803 \n",
       "L 500 4441 \n",
       "Q 881 4594 1212 4672 \n",
       "Q 1544 4750 1819 4750 \n",
       "Q 2544 4750 2975 4387 \n",
       "Q 3406 4025 3406 3419 \n",
       "Q 3406 3131 3298 2873 \n",
       "Q 3191 2616 2906 2266 \n",
       "Q 2828 2175 2409 1742 \n",
       "Q 1991 1309 1228 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-2212\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"83.789062\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_2\">\n",
       "     <g id=\"line2d_3\">\n",
       "      <path d=\"M 136.105847 158.218125 \n",
       "L 136.105847 22.318125 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_4\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3f3480c4d5\" x=\"136.105847\" y=\"158.218125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_2\">\n",
       "      <!-- 0 -->\n",
       "      <g transform=\"translate(132.924597 172.816562)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-30\" d=\"M 2034 4250 \n",
       "Q 1547 4250 1301 3770 \n",
       "Q 1056 3291 1056 2328 \n",
       "Q 1056 1369 1301 889 \n",
       "Q 1547 409 2034 409 \n",
       "Q 2525 409 2770 889 \n",
       "Q 3016 1369 3016 2328 \n",
       "Q 3016 3291 2770 3770 \n",
       "Q 2525 4250 2034 4250 \n",
       "z\n",
       "M 2034 4750 \n",
       "Q 2819 4750 3233 4129 \n",
       "Q 3647 3509 3647 2328 \n",
       "Q 3647 1150 3233 529 \n",
       "Q 2819 -91 2034 -91 \n",
       "Q 1250 -91 836 529 \n",
       "Q 422 1150 422 2328 \n",
       "Q 422 3509 836 4129 \n",
       "Q 1250 4750 2034 4750 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"xtick_3\">\n",
       "     <g id=\"line2d_5\">\n",
       "      <path d=\"M 198.512034 158.218125 \n",
       "L 198.512034 22.318125 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_6\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#m3f3480c4d5\" x=\"198.512034\" y=\"158.218125\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_3\">\n",
       "      <!-- 2 -->\n",
       "      <g transform=\"translate(195.330784 172.816562)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-32\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_4\">\n",
       "     <!-- x -->\n",
       "     <g transform=\"translate(138.471875 186.494687)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-78\" d=\"M 3513 3500 \n",
       "L 2247 1797 \n",
       "L 3578 0 \n",
       "L 2900 0 \n",
       "L 1881 1375 \n",
       "L 863 0 \n",
       "L 184 0 \n",
       "L 1544 1831 \n",
       "L 300 3500 \n",
       "L 978 3500 \n",
       "L 1906 2253 \n",
       "L 2834 3500 \n",
       "L 3513 3500 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-78\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"matplotlib.axis_2\">\n",
       "    <g id=\"ytick_1\">\n",
       "     <g id=\"line2d_7\">\n",
       "      <path d=\"M 43.78125 153.36418 \n",
       "L 239.08125 153.36418 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_8\">\n",
       "      <defs>\n",
       "       <path id=\"mea5ed35759\" d=\"M 0 0 \n",
       "L -3.5 0 \n",
       "\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </defs>\n",
       "      <g>\n",
       "       <use xlink:href=\"#mea5ed35759\" x=\"43.78125\" y=\"153.36418\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_5\">\n",
       "      <!-- 0.0 -->\n",
       "      <g transform=\"translate(20.878125 157.163399)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-2e\" d=\"M 684 794 \n",
       "L 1344 794 \n",
       "L 1344 0 \n",
       "L 684 0 \n",
       "L 684 794 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-30\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_2\">\n",
       "     <g id=\"line2d_9\">\n",
       "      <path d=\"M 43.78125 122.063925 \n",
       "L 239.08125 122.063925 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_10\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mea5ed35759\" x=\"43.78125\" y=\"122.063925\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_6\">\n",
       "      <!-- 0.1 -->\n",
       "      <g transform=\"translate(20.878125 125.863143)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-31\" d=\"M 794 531 \n",
       "L 1825 531 \n",
       "L 1825 4091 \n",
       "L 703 3866 \n",
       "L 703 4441 \n",
       "L 1819 4666 \n",
       "L 2450 4666 \n",
       "L 2450 531 \n",
       "L 3481 531 \n",
       "L 3481 0 \n",
       "L 794 0 \n",
       "L 794 531 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-31\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_3\">\n",
       "     <g id=\"line2d_11\">\n",
       "      <path d=\"M 43.78125 90.763669 \n",
       "L 239.08125 90.763669 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_12\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mea5ed35759\" x=\"43.78125\" y=\"90.763669\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_7\">\n",
       "      <!-- 0.2 -->\n",
       "      <g transform=\"translate(20.878125 94.562887)scale(0.1 -0.1)\">\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-32\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_4\">\n",
       "     <g id=\"line2d_13\">\n",
       "      <path d=\"M 43.78125 59.463413 \n",
       "L 239.08125 59.463413 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_14\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mea5ed35759\" x=\"43.78125\" y=\"59.463413\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_8\">\n",
       "      <!-- 0.3 -->\n",
       "      <g transform=\"translate(20.878125 63.262632)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-33\" d=\"M 2597 2516 \n",
       "Q 3050 2419 3304 2112 \n",
       "Q 3559 1806 3559 1356 \n",
       "Q 3559 666 3084 287 \n",
       "Q 2609 -91 1734 -91 \n",
       "Q 1441 -91 1130 -33 \n",
       "Q 819 25 488 141 \n",
       "L 488 750 \n",
       "Q 750 597 1062 519 \n",
       "Q 1375 441 1716 441 \n",
       "Q 2309 441 2620 675 \n",
       "Q 2931 909 2931 1356 \n",
       "Q 2931 1769 2642 2001 \n",
       "Q 2353 2234 1838 2234 \n",
       "L 1294 2234 \n",
       "L 1294 2753 \n",
       "L 1863 2753 \n",
       "Q 2328 2753 2575 2939 \n",
       "Q 2822 3125 2822 3475 \n",
       "Q 2822 3834 2567 4026 \n",
       "Q 2313 4219 1838 4219 \n",
       "Q 1578 4219 1281 4162 \n",
       "Q 984 4106 628 3988 \n",
       "L 628 4550 \n",
       "Q 988 4650 1302 4700 \n",
       "Q 1616 4750 1894 4750 \n",
       "Q 2613 4750 3031 4423 \n",
       "Q 3450 4097 3450 3541 \n",
       "Q 3450 3153 3228 2886 \n",
       "Q 3006 2619 2597 2516 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-33\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"ytick_5\">\n",
       "     <g id=\"line2d_15\">\n",
       "      <path d=\"M 43.78125 28.163157 \n",
       "L 239.08125 28.163157 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #b0b0b0; stroke-width: 0.8; stroke-linecap: square\"/>\n",
       "     </g>\n",
       "     <g id=\"line2d_16\">\n",
       "      <g>\n",
       "       <use xlink:href=\"#mea5ed35759\" x=\"43.78125\" y=\"28.163157\" style=\"stroke: #000000; stroke-width: 0.8\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "     <g id=\"text_9\">\n",
       "      <!-- 0.4 -->\n",
       "      <g transform=\"translate(20.878125 31.962376)scale(0.1 -0.1)\">\n",
       "       <defs>\n",
       "        <path id=\"DejaVuSans-34\" d=\"M 2419 4116 \n",
       "L 825 1625 \n",
       "L 2419 1625 \n",
       "L 2419 4116 \n",
       "z\n",
       "M 2253 4666 \n",
       "L 3047 4666 \n",
       "L 3047 1625 \n",
       "L 3713 1625 \n",
       "L 3713 1100 \n",
       "L 3047 1100 \n",
       "L 3047 0 \n",
       "L 2419 0 \n",
       "L 2419 1100 \n",
       "L 313 1100 \n",
       "L 313 1709 \n",
       "L 2253 4666 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       </defs>\n",
       "       <use xlink:href=\"#DejaVuSans-30\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-2e\" x=\"63.623047\"/>\n",
       "       <use xlink:href=\"#DejaVuSans-34\" x=\"95.410156\"/>\n",
       "      </g>\n",
       "     </g>\n",
       "    </g>\n",
       "    <g id=\"text_10\">\n",
       "     <!-- density -->\n",
       "     <g transform=\"translate(14.798438 108.600937)rotate(-90)scale(0.1 -0.1)\">\n",
       "      <defs>\n",
       "       <path id=\"DejaVuSans-64\" d=\"M 2906 2969 \n",
       "L 2906 4863 \n",
       "L 3481 4863 \n",
       "L 3481 0 \n",
       "L 2906 0 \n",
       "L 2906 525 \n",
       "Q 2725 213 2448 61 \n",
       "Q 2172 -91 1784 -91 \n",
       "Q 1150 -91 751 415 \n",
       "Q 353 922 353 1747 \n",
       "Q 353 2572 751 3078 \n",
       "Q 1150 3584 1784 3584 \n",
       "Q 2172 3584 2448 3432 \n",
       "Q 2725 3281 2906 2969 \n",
       "z\n",
       "M 947 1747 \n",
       "Q 947 1113 1208 752 \n",
       "Q 1469 391 1925 391 \n",
       "Q 2381 391 2643 752 \n",
       "Q 2906 1113 2906 1747 \n",
       "Q 2906 2381 2643 2742 \n",
       "Q 2381 3103 1925 3103 \n",
       "Q 1469 3103 1208 2742 \n",
       "Q 947 2381 947 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-65\" d=\"M 3597 1894 \n",
       "L 3597 1613 \n",
       "L 953 1613 \n",
       "Q 991 1019 1311 708 \n",
       "Q 1631 397 2203 397 \n",
       "Q 2534 397 2845 478 \n",
       "Q 3156 559 3463 722 \n",
       "L 3463 178 \n",
       "Q 3153 47 2828 -22 \n",
       "Q 2503 -91 2169 -91 \n",
       "Q 1331 -91 842 396 \n",
       "Q 353 884 353 1716 \n",
       "Q 353 2575 817 3079 \n",
       "Q 1281 3584 2069 3584 \n",
       "Q 2775 3584 3186 3129 \n",
       "Q 3597 2675 3597 1894 \n",
       "z\n",
       "M 3022 2063 \n",
       "Q 3016 2534 2758 2815 \n",
       "Q 2500 3097 2075 3097 \n",
       "Q 1594 3097 1305 2825 \n",
       "Q 1016 2553 972 2059 \n",
       "L 3022 2063 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-6e\" d=\"M 3513 2113 \n",
       "L 3513 0 \n",
       "L 2938 0 \n",
       "L 2938 2094 \n",
       "Q 2938 2591 2744 2837 \n",
       "Q 2550 3084 2163 3084 \n",
       "Q 1697 3084 1428 2787 \n",
       "Q 1159 2491 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1366 3272 1645 3428 \n",
       "Q 1925 3584 2291 3584 \n",
       "Q 2894 3584 3203 3211 \n",
       "Q 3513 2838 3513 2113 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-73\" d=\"M 2834 3397 \n",
       "L 2834 2853 \n",
       "Q 2591 2978 2328 3040 \n",
       "Q 2066 3103 1784 3103 \n",
       "Q 1356 3103 1142 2972 \n",
       "Q 928 2841 928 2578 \n",
       "Q 928 2378 1081 2264 \n",
       "Q 1234 2150 1697 2047 \n",
       "L 1894 2003 \n",
       "Q 2506 1872 2764 1633 \n",
       "Q 3022 1394 3022 966 \n",
       "Q 3022 478 2636 193 \n",
       "Q 2250 -91 1575 -91 \n",
       "Q 1294 -91 989 -36 \n",
       "Q 684 19 347 128 \n",
       "L 347 722 \n",
       "Q 666 556 975 473 \n",
       "Q 1284 391 1588 391 \n",
       "Q 1994 391 2212 530 \n",
       "Q 2431 669 2431 922 \n",
       "Q 2431 1156 2273 1281 \n",
       "Q 2116 1406 1581 1522 \n",
       "L 1381 1569 \n",
       "Q 847 1681 609 1914 \n",
       "Q 372 2147 372 2553 \n",
       "Q 372 3047 722 3315 \n",
       "Q 1072 3584 1716 3584 \n",
       "Q 2034 3584 2315 3537 \n",
       "Q 2597 3491 2834 3397 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-69\" d=\"M 603 3500 \n",
       "L 1178 3500 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 3500 \n",
       "z\n",
       "M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 4134 \n",
       "L 603 4134 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-74\" d=\"M 1172 4494 \n",
       "L 1172 3500 \n",
       "L 2356 3500 \n",
       "L 2356 3053 \n",
       "L 1172 3053 \n",
       "L 1172 1153 \n",
       "Q 1172 725 1289 603 \n",
       "Q 1406 481 1766 481 \n",
       "L 2356 481 \n",
       "L 2356 0 \n",
       "L 1766 0 \n",
       "Q 1100 0 847 248 \n",
       "Q 594 497 594 1153 \n",
       "L 594 3053 \n",
       "L 172 3053 \n",
       "L 172 3500 \n",
       "L 594 3500 \n",
       "L 594 4494 \n",
       "L 1172 4494 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "       <path id=\"DejaVuSans-79\" d=\"M 2059 -325 \n",
       "Q 1816 -950 1584 -1140 \n",
       "Q 1353 -1331 966 -1331 \n",
       "L 506 -1331 \n",
       "L 506 -850 \n",
       "L 844 -850 \n",
       "Q 1081 -850 1212 -737 \n",
       "Q 1344 -625 1503 -206 \n",
       "L 1606 56 \n",
       "L 191 3500 \n",
       "L 800 3500 \n",
       "L 1894 763 \n",
       "L 2988 3500 \n",
       "L 3597 3500 \n",
       "L 2059 -325 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      </defs>\n",
       "      <use xlink:href=\"#DejaVuSans-64\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-65\" x=\"63.476562\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-6e\" x=\"125\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-73\" x=\"188.378906\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-69\" x=\"240.478516\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-74\" x=\"268.261719\"/>\n",
       "      <use xlink:href=\"#DejaVuSans-79\" x=\"307.470703\"/>\n",
       "     </g>\n",
       "    </g>\n",
       "   </g>\n",
       "   <g id=\"line2d_17\">\n",
       "    <path d=\"M 52.658523 149.86945 \n",
       "L 55.778829 148.820721 \n",
       "L 58.587105 147.659265 \n",
       "L 61.395381 146.258692 \n",
       "L 64.203656 144.585668 \n",
       "L 66.699901 142.84234 \n",
       "L 69.196146 140.833258 \n",
       "L 71.692392 138.535764 \n",
       "L 74.188637 135.928974 \n",
       "L 76.684882 132.994699 \n",
       "L 79.181127 129.718417 \n",
       "L 81.677372 126.09028 \n",
       "L 84.485648 121.583144 \n",
       "L 87.293923 116.62994 \n",
       "L 90.41423 110.623888 \n",
       "L 93.534536 104.130652 \n",
       "L 97.278904 95.788841 \n",
       "L 101.959363 84.750382 \n",
       "L 112.880436 58.707265 \n",
       "L 116.312773 51.250654 \n",
       "L 119.121048 45.688368 \n",
       "L 121.617293 41.255214 \n",
       "L 123.801508 37.834841 \n",
       "L 125.673692 35.281591 \n",
       "L 127.545876 33.10562 \n",
       "L 129.10603 31.597025 \n",
       "L 130.666186 30.377363 \n",
       "L 132.226341 29.455634 \n",
       "L 133.786495 28.838713 \n",
       "L 135.034619 28.567794 \n",
       "L 136.282742 28.496237 \n",
       "L 137.530866 28.624379 \n",
       "L 138.77899 28.951612 \n",
       "L 140.027113 29.476361 \n",
       "L 141.587269 30.406159 \n",
       "L 143.147424 31.633685 \n",
       "L 144.707578 33.149873 \n",
       "L 146.579762 35.334519 \n",
       "L 148.451946 37.895904 \n",
       "L 150.63616 41.324961 \n",
       "L 152.820376 45.183563 \n",
       "L 155.316621 50.052679 \n",
       "L 158.124896 56.016526 \n",
       "L 161.557234 63.830473 \n",
       "L 166.861754 76.541367 \n",
       "L 174.35049 94.446489 \n",
       "L 178.406888 103.547257 \n",
       "L 181.839225 110.707609 \n",
       "L 184.959531 116.706807 \n",
       "L 187.767807 121.653462 \n",
       "L 190.576083 126.153903 \n",
       "L 193.384358 130.203992 \n",
       "L 195.880604 133.431084 \n",
       "L 198.376849 136.317963 \n",
       "L 200.873097 138.879742 \n",
       "L 203.369343 141.135041 \n",
       "L 205.865588 143.105048 \n",
       "L 208.361833 144.81261 \n",
       "L 211.170108 146.449441 \n",
       "L 213.978384 147.818078 \n",
       "L 216.78666 148.951707 \n",
       "L 219.906966 149.974047 \n",
       "L 223.339303 150.856405 \n",
       "L 227.083671 151.583997 \n",
       "L 230.203977 152.040852 \n",
       "L 230.203977 152.040852 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_18\">\n",
       "    <path d=\"M 136.105847 158.218125 \n",
       "L 136.105847 22.318125 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke: #1f77b4; stroke-width: 1.5; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"line2d_19\">\n",
       "    <path d=\"M 135.927634 158.218125 \n",
       "L 135.927634 22.318125 \n",
       "\" clip-path=\"url(#pc76972f4af)\" style=\"fill: none; stroke-dasharray: 5.55,2.4; stroke-dashoffset: 0; stroke: #800080; stroke-width: 1.5\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_3\">\n",
       "    <path d=\"M 43.78125 158.218125 \n",
       "L 43.78125 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_4\">\n",
       "    <path d=\"M 239.08125 158.218125 \n",
       "L 239.08125 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_5\">\n",
       "    <path d=\"M 43.78125 158.218125 \n",
       "L 239.08125 158.218125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"patch_6\">\n",
       "    <path d=\"M 43.78125 22.318125 \n",
       "L 239.08125 22.318125 \n",
       "\" style=\"fill: none; stroke: #000000; stroke-width: 0.8; stroke-linejoin: miter; stroke-linecap: square\"/>\n",
       "   </g>\n",
       "   <g id=\"text_11\">\n",
       "    <!-- sample mean: -0.01 -->\n",
       "    <g transform=\"translate(81.241875 16.318125)scale(0.12 -0.12)\">\n",
       "     <defs>\n",
       "      <path id=\"DejaVuSans-61\" d=\"M 2194 1759 \n",
       "Q 1497 1759 1228 1600 \n",
       "Q 959 1441 959 1056 \n",
       "Q 959 750 1161 570 \n",
       "Q 1363 391 1709 391 \n",
       "Q 2188 391 2477 730 \n",
       "Q 2766 1069 2766 1631 \n",
       "L 2766 1759 \n",
       "L 2194 1759 \n",
       "z\n",
       "M 3341 1997 \n",
       "L 3341 0 \n",
       "L 2766 0 \n",
       "L 2766 531 \n",
       "Q 2569 213 2275 61 \n",
       "Q 1981 -91 1556 -91 \n",
       "Q 1019 -91 701 211 \n",
       "Q 384 513 384 1019 \n",
       "Q 384 1609 779 1909 \n",
       "Q 1175 2209 1959 2209 \n",
       "L 2766 2209 \n",
       "L 2766 2266 \n",
       "Q 2766 2663 2505 2880 \n",
       "Q 2244 3097 1772 3097 \n",
       "Q 1472 3097 1187 3025 \n",
       "Q 903 2953 641 2809 \n",
       "L 641 3341 \n",
       "Q 956 3463 1253 3523 \n",
       "Q 1550 3584 1831 3584 \n",
       "Q 2591 3584 2966 3190 \n",
       "Q 3341 2797 3341 1997 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-6d\" d=\"M 3328 2828 \n",
       "Q 3544 3216 3844 3400 \n",
       "Q 4144 3584 4550 3584 \n",
       "Q 5097 3584 5394 3201 \n",
       "Q 5691 2819 5691 2113 \n",
       "L 5691 0 \n",
       "L 5113 0 \n",
       "L 5113 2094 \n",
       "Q 5113 2597 4934 2840 \n",
       "Q 4756 3084 4391 3084 \n",
       "Q 3944 3084 3684 2787 \n",
       "Q 3425 2491 3425 1978 \n",
       "L 3425 0 \n",
       "L 2847 0 \n",
       "L 2847 2094 \n",
       "Q 2847 2600 2669 2842 \n",
       "Q 2491 3084 2119 3084 \n",
       "Q 1678 3084 1418 2786 \n",
       "Q 1159 2488 1159 1978 \n",
       "L 1159 0 \n",
       "L 581 0 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2956 \n",
       "Q 1356 3278 1631 3431 \n",
       "Q 1906 3584 2284 3584 \n",
       "Q 2666 3584 2933 3390 \n",
       "Q 3200 3197 3328 2828 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-70\" d=\"M 1159 525 \n",
       "L 1159 -1331 \n",
       "L 581 -1331 \n",
       "L 581 3500 \n",
       "L 1159 3500 \n",
       "L 1159 2969 \n",
       "Q 1341 3281 1617 3432 \n",
       "Q 1894 3584 2278 3584 \n",
       "Q 2916 3584 3314 3078 \n",
       "Q 3713 2572 3713 1747 \n",
       "Q 3713 922 3314 415 \n",
       "Q 2916 -91 2278 -91 \n",
       "Q 1894 -91 1617 61 \n",
       "Q 1341 213 1159 525 \n",
       "z\n",
       "M 3116 1747 \n",
       "Q 3116 2381 2855 2742 \n",
       "Q 2594 3103 2138 3103 \n",
       "Q 1681 3103 1420 2742 \n",
       "Q 1159 2381 1159 1747 \n",
       "Q 1159 1113 1420 752 \n",
       "Q 1681 391 2138 391 \n",
       "Q 2594 391 2855 752 \n",
       "Q 3116 1113 3116 1747 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-6c\" d=\"M 603 4863 \n",
       "L 1178 4863 \n",
       "L 1178 0 \n",
       "L 603 0 \n",
       "L 603 4863 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-20\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-3a\" d=\"M 750 794 \n",
       "L 1409 794 \n",
       "L 1409 0 \n",
       "L 750 0 \n",
       "L 750 794 \n",
       "z\n",
       "M 750 3309 \n",
       "L 1409 3309 \n",
       "L 1409 2516 \n",
       "L 750 2516 \n",
       "L 750 3309 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "      <path id=\"DejaVuSans-2d\" d=\"M 313 2009 \n",
       "L 1997 2009 \n",
       "L 1997 1497 \n",
       "L 313 1497 \n",
       "L 313 2009 \n",
       "z\n",
       "\" transform=\"scale(0.015625)\"/>\n",
       "     </defs>\n",
       "     <use xlink:href=\"#DejaVuSans-73\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"52.099609\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6d\" x=\"113.378906\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-70\" x=\"210.791016\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6c\" x=\"274.267578\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"302.050781\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"363.574219\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6d\" x=\"395.361328\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-65\" x=\"492.773438\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-61\" x=\"554.296875\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-6e\" x=\"615.576172\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-3a\" x=\"678.955078\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-20\" x=\"712.646484\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2d\" x=\"744.433594\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-30\" x=\"780.517578\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-2e\" x=\"844.140625\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-30\" x=\"875.927734\"/>\n",
       "     <use xlink:href=\"#DejaVuSans-31\" x=\"939.550781\"/>\n",
       "    </g>\n",
       "   </g>\n",
       "  </g>\n",
       " </g>\n",
       " <defs>\n",
       "  <clipPath id=\"pc76972f4af\">\n",
       "   <rect x=\"43.78125\" y=\"22.318125\" width=\"195.3\" height=\"135.9\"/>\n",
       "  </clipPath>\n",
       " </defs>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<Figure size 252x180 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "from d2l import tensorflow as d2l\n",
    "\n",
    "tf.pi = tf.acos(tf.zeros(1)) * 2  # define pi in TensorFlow\n",
    "\n",
    "# Sample datapoints and create y coordinate\n",
    "epsilon = 0.1\n",
    "xs = tf.random.normal((300,))\n",
    "\n",
    "ys = tf.constant(\n",
    "    [(tf.reduce_sum(tf.exp(-(xs[:i] - xs[i])**2 / (2 * epsilon**2)) \\\n",
    "               / tf.sqrt(2*tf.pi*epsilon**2)) / tf.cast(\n",
    "        tf.size(xs), dtype=tf.float32)).numpy() \\\n",
    "     for i in range(tf.size(xs))])\n",
    "\n",
    "# Compute true density\n",
    "xd = tf.range(tf.reduce_min(xs), tf.reduce_max(xs), 0.01)\n",
    "yd = tf.exp(-xd**2/2) / tf.sqrt(2 * tf.pi)\n",
    "\n",
    "# Plot the results\n",
    "d2l.plot(xd, yd, 'x', 'density')\n",
    "d2l.plt.scatter(xs, ys)\n",
    "d2l.plt.axvline(x=0)\n",
    "d2l.plt.axvline(x=tf.reduce_mean(xs), linestyle='--', color='purple')\n",
    "d2l.plt.title(f'sample mean: {float(tf.reduce_mean(xs).numpy()):.2f}')\n",
    "d2l.plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 4
   },
   "source": [
    "There can be many ways to compute an estimator of a parameter $\\hat{\\theta}_n$.  In this section, we introduce three common methods to evaluate and compare estimators: the mean squared error, the standard deviation, and statistical bias.\n",
    "\n",
    "### Mean Squared Error\n",
    "\n",
    "Perhaps the simplest metric used to evaluate estimators is the *mean squared error (MSE)* (or $l_2$ loss) of an estimator can be defined as\n",
    "\n",
    "$$\\mathrm{MSE} (\\hat{\\theta}_n, \\theta) = E[(\\hat{\\theta}_n - \\theta)^2].$$\n",
    ":eqlabel:`eq_mse_est`\n",
    "\n",
    "This allows us to quantify the average squared deviation from the true value.  MSE is always non-negative. If you have read :numref:`sec_linear_regression`, you will recognize it as the most commonly used regression loss function. As a measure to evaluate an estimator, the closer its value to zero, the closer the estimator is close to the true parameter $\\theta$.\n",
    "\n",
    "\n",
    "### Statistical Bias\n",
    "\n",
    "The MSE provides a natural metric, but we can easily imagine multiple different phenomena that might make it large.  Two fundamentally important are fluctuation in the estimator due to randomness in the dataset, and systematic error in the estimator due to the estimation procedure.\n",
    "\n",
    "\n",
    "First, let us measure the systematic error. For an estimator $\\hat{\\theta}_n$, the mathematical illustration of *statistical bias* can be defined as\n",
    "\n",
    "$$\\mathrm{bias}(\\hat{\\theta}_n) = E(\\hat{\\theta}_n - \\theta) = E(\\hat{\\theta}_n) - \\theta.$$\n",
    ":eqlabel:`eq_bias`\n",
    "\n",
    "Note that when $\\mathrm{bias}(\\hat{\\theta}_n) = 0$, the expectation of the estimator $\\hat{\\theta}_n$ is equal to the true value of parameter.  In this case, we say $\\hat{\\theta}_n$ is an unbiased estimator.  In general, an unbiased estimator is better than a biased estimator since its expectation is the same as the true parameter.\n",
    "\n",
    "\n",
    "It is worth being aware, however, that biased estimators are frequently used in practice.  There are cases where unbiased estimators do not exist without further assumptions, or are intractable to compute.  This may seem like a significant flaw in an estimator, however the majority of estimators encountered in practice are at least asymptotically unbiased in the sense that the bias tends to zero as the number of available samples tends to infinity: $\\lim_{n \\rightarrow \\infty} \\mathrm{bias}(\\hat{\\theta}_n) = 0$.\n",
    "\n",
    "\n",
    "### Variance and Standard Deviation\n",
    "\n",
    "Second, let us measure the randomness in the estimator.  Recall from :numref:`sec_random_variables`, the *standard deviation* (or *standard error*) is defined as the squared root of the variance.  We may measure the degree of fluctuation of an estimator by measuring the standard deviation or variance of that estimator.\n",
    "\n",
    "$$\\sigma_{\\hat{\\theta}_n} = \\sqrt{\\mathrm{Var} (\\hat{\\theta}_n )} = \\sqrt{E[(\\hat{\\theta}_n - E(\\hat{\\theta}_n))^2]}.$$\n",
    ":eqlabel:`eq_var_est`\n",
    "\n",
    "It is important to compare :eqref:`eq_var_est` to :eqref:`eq_mse_est`.  In this equation we do not compare to the true population value $\\theta$, but instead to $E(\\hat{\\theta}_n)$, the expected sample mean.  Thus we are not measuring how far the estimator tends to be from the true value, but instead we measuring the fluctuation of the estimator itself.\n",
    "\n",
    "\n",
    "### The Bias-Variance Trade-off\n",
    "\n",
    "It is intuitively clear that these two main components contribute to the mean squared error.  What is somewhat shocking is that we can show that this is actually a *decomposition* of the mean squared error into these two contributions plus a third one. That is to say that we can write the mean squared error as the sum of the square of the bias, the variance and the irreducible error.\n",
    "\n",
    "$$\n",
    "\\begin{aligned}\n",
    "\\mathrm{MSE} (\\hat{\\theta}_n, \\theta) &= E[(\\hat{\\theta}_n - \\theta)^2] \\\\\n",
    " &= E[(\\hat{\\theta}_n)^2] + E[\\theta^2] - 2E[\\hat{\\theta}_n\\theta] \\\\\n",
    " &= \\mathrm{Var} [\\hat{\\theta}_n] + E[\\hat{\\theta}_n]^2 + \\mathrm{Var} [\\theta] + E[\\theta]^2 - 2E[\\hat{\\theta}_n]E[\\theta] \\\\\n",
    " &= (E[\\hat{\\theta}_n] - E[\\theta])^2 + \\mathrm{Var} [\\hat{\\theta}_n] + \\mathrm{Var} [\\theta] \\\\\n",
    " &= (E[\\hat{\\theta}_n - \\theta])^2 + \\mathrm{Var} [\\hat{\\theta}_n] + \\mathrm{Var} [\\theta] \\\\\n",
    " &= (\\mathrm{bias} [\\hat{\\theta}_n])^2 + \\mathrm{Var} (\\hat{\\theta}_n) + \\mathrm{Var} [\\theta].\\\\\n",
    "\\end{aligned}\n",
    "$$\n",
    "\n",
    "We refer the above formula as *bias-variance trade-off*. The mean squared error can be divided into three sources of error: the error from high bias, the error from high variance and the irreducible error. The bias error is commonly seen in a simple model (such as a linear regression model), which cannot extract high dimensional relations between the features and the outputs. If a model suffers from high bias error, we often say it is *underfitting* or lack of *flexibilty* as introduced in (:numref:`sec_model_selection`). The high variance usually results from a too complex model, which overfits the training data. As a result, an *overfitting* model is sensitive to small fluctuations in the data. If a model suffers from high variance, we often say it is *overfitting* and lack of *generalization* as introduced in (:numref:`sec_model_selection`). The irreducible error is the result from noise in the $\\theta$ itself.\n",
    "\n",
    "\n",
    "### Evaluating Estimators in Code\n",
    "\n",
    "Since the standard deviation of an estimator has been implementing by simply calling `a.std()` for a tensor `a`, we will skip it but implement the statistical bias and the mean squared error.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "origin_pos": 7,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [],
   "source": [
    "# Statistical bias\n",
    "def stat_bias(true_theta, est_theta):\n",
    "    return(tf.reduce_mean(est_theta) - true_theta)\n",
    "\n",
    "# Mean squared error\n",
    "def mse(data, true_theta):\n",
    "    return(tf.reduce_mean(tf.square(data - true_theta)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 8
   },
   "source": [
    "To illustrate the equation of the bias-variance trade-off, let us simulate of normal distribution $\\mathcal{N}(\\theta, \\sigma^2)$ with $10,000$ samples. Here, we use a $\\theta = 1$ and $\\sigma = 4$. As the estimator is a function of the given samples, here we use the mean of the samples as an estimator for true $\\theta$ in this normal distribution $\\mathcal{N}(\\theta, \\sigma^2)$ .\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "origin_pos": 11,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(), dtype=float32, numpy=0.9488372>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "theta_true = 1\n",
    "sigma = 4\n",
    "sample_len = 10000\n",
    "samples = tf.random.normal((sample_len, 1), theta_true, sigma)\n",
    "theta_est = tf.reduce_mean(samples)\n",
    "theta_est"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 12
   },
   "source": [
    "Let us validate the trade-off equation by calculating the summation of the squared bias and the variance of our estimator. First, calculate the MSE of our estimator.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "origin_pos": 13,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(), dtype=float32, numpy=16.394075>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse(samples, theta_true)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 14
   },
   "source": [
    "Next, we calculate $\\mathrm{Var} (\\hat{\\theta}_n) + [\\mathrm{bias} (\\hat{\\theta}_n)]^2$ as below. As you can see, the two values agree to numerical precision.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "origin_pos": 17,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(), dtype=float32, numpy=16.394073>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bias = stat_bias(theta_true, theta_est)\n",
    "tf.square(tf.math.reduce_std(samples)) + tf.square(bias)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 18
   },
   "source": [
    "## Conducting Hypothesis Tests\n",
    "\n",
    "\n",
    "The most commonly encountered topic in statistical inference is hypothesis testing. While hypothesis testing was popularized in the early 20th century, the first use can be traced back to John Arbuthnot in the 1700s. John tracked 80-year birth records in London and concluded that more men were born than women each year. Following that, the modern significance testing is the intelligence heritage by Karl Pearson who invented $p$-value and Pearson's chi-squared test, William Gosset who is the father of Student's t-distribution, and Ronald Fisher who initialed the null hypothesis and the significance test.\n",
    "\n",
    "A *hypothesis test* is a way of evaluating some evidence against the default statement about a population. We refer the default statement as the *null hypothesis* $H_0$, which we try to reject using the observed data. Here, we use $H_0$ as a starting point for the statistical significance testing. The *alternative hypothesis* $H_A$ (or $H_1$) is a statement that is contrary to the null hypothesis. A null hypothesis is often stated in a declarative form which posits a relationship between variables. It should reflect the brief as explicit as possible, and be testable by statistics theory.\n",
    "\n",
    "Imagine you are a chemist. After spending thousands of hours in the lab, you develop a new medicine which can dramatically improve one's ability to understand math. To show its magic power, you need to test it. Naturally, you may need some volunteers to take the medicine and see whether it can help them learn math better. How do you get started?\n",
    "\n",
    "First, you will need carefully random selected two groups of volunteers, so that there is no difference between their math understanding ability measured by some metrics. The two groups are commonly referred to as the test group and the control group. The *test group* (or *treatment group*) is a group of individuals who will experience the medicine, while the *control group* represents the group of users who are set aside as a benchmark, i.e., identical environment setups except taking this medicine. In this way, the influence of all the variables are minimized, except the impact of the independent variable in the treatment.\n",
    "\n",
    "Second, after a period of taking the medicine, you will need to measure the two groups' math understanding by the same metrics, such as letting the volunteers do the same tests after learning a new math formula. Then, you can collect their performance and compare the results.  In this case, our null hypothesis will be that there is no difference between the two groups, and our alternate will be that there is.\n",
    "\n",
    "This is still not fully formal.  There are many details you have to think of carefully. For example, what is the suitable metrics to test their math understanding ability? How many volunteers for your test so you can be confident to claim the effectiveness of your medicine? How long should you run the test? How do you decide if there is a difference between the two groups?  Do you care about the average performance only, or also the range of variation of the scores? And so on.\n",
    "\n",
    "In this way, hypothesis testing provides a framework for experimental design and reasoning about certainty in observed results.  If we can now show that the null hypothesis is very unlikely to be true, we may reject it with confidence.\n",
    "\n",
    "To complete the story of how to work with hypothesis testing, we need to now introduce some additional terminology and make some of our concepts above formal.\n",
    "\n",
    "\n",
    "### Statistical Significance\n",
    "\n",
    "The *statistical significance* measures the probability of erroneously rejecting the null hypothesis, $H_0$, when it should not be rejected, i.e.,\n",
    "\n",
    "$$ \\text{statistical significance }= 1 - \\alpha = 1 - P(\\text{reject } H_0 \\mid H_0 \\text{ is true} ).$$\n",
    "\n",
    "It is also referred to as the *type I error* or *false positive*. The $\\alpha$, is called as the *significance level* and its commonly used value is $5\\%$, i.e., $1-\\alpha = 95\\%$. The significance level can be explained as the level of risk that we are willing to take, when we reject a true null hypothesis.\n",
    "\n",
    ":numref:`fig_statistical_significance` shows the observations' values and probability of a given normal distribution in a two-sample hypothesis test. If the observation data example is located outsides the $95\\%$ threshold, it will be a very unlikely observation under the null hypothesis assumption. Hence, there might be something wrong with the null hypothesis and we will reject it.\n",
    "\n",
    "![Statistical significance.](../img/statistical-significance.svg)\n",
    ":label:`fig_statistical_significance`\n",
    "\n",
    "\n",
    "### Statistical Power\n",
    "\n",
    "The *statistical power* (or *sensitivity*) measures the probability of reject the null hypothesis, $H_0$, when it should be rejected, i.e.,\n",
    "\n",
    "$$ \\text{statistical power }= 1 - \\beta = 1 - P(\\text{ fail to reject } H_0  \\mid H_0 \\text{ is false} ).$$\n",
    "\n",
    "Recall that a *type I error* is error caused by rejecting the null hypothesis when it is true, whereas a *type II error* is resulted from failing to reject the null hypothesis when it is false. A type II error is usually denoted as $\\beta$, and hence the corresponding statistical power is $1-\\beta$.\n",
    "\n",
    "\n",
    "Intuitively, statistical power can be interpreted as how likely our test will detect a real discrepancy of some minimum magnitude at a desired statistical significance level. $80\\%$ is a commonly used statistical power threshold. The higher the statistical power, the more likely we are to detect true differences.\n",
    "\n",
    "One of the most common uses of statistical power is in determining the number of samples needed.  The probability you reject the null hypothesis when it is false depends on the degree to which it is false (known as the *effect size*) and the number of samples you have.  As you might expect, small effect sizes will require a very large number of samples to be detectable with high probability.  While beyond the scope of this brief appendix to derive in detail, as an example, want to be able to reject a null hypothesis that our sample came from a mean zero variance one Gaussian, and we believe that our sample's mean is actually close to one, we can do so with acceptable error rates with a sample size of only $8$.  However, if we think our sample population true mean is close to $0.01$, then we'd need a sample size of nearly $80000$ to detect the difference.\n",
    "\n",
    "We can imagine the power as a water filter. In this analogy, a high power hypothesis test is like a high quality water filtration system that will reduce harmful substances in the water as much as possible. On the other hand, a smaller discrepancy is like a low quality water filter, where some relative small substances may easily escape from the gaps. Similarly, if the statistical power is not of enough high power, then the test may not catch the smaller discrepancy.\n",
    "\n",
    "\n",
    "### Test Statistic\n",
    "\n",
    "A *test statistic* $T(x)$ is a scalar which summarizes some characteristic of the sample data.  The goal of defining such a statistic is that it should allow us to distinguish between different distributions and conduct our hypothesis test.  Thinking back to our chemist example, if we wish to show that one population performs better than the other, it could be reasonable to take the mean as the test statistic.  Different choices of test statistic can lead to statistical test with drastically different statistical power.\n",
    "\n",
    "Often, $T(X)$ (the distribution of the test statistic under our null hypothesis) will follow, at least approximately, a common probability distribution such as a normal distribution when considered under the null hypothesis. If we can derive explicitly such a distribution, and then measure our test statistic on our dataset, we can safely reject the null hypothesis if our statistic is far outside the range that we would expect.  Making this quantitative leads us to the notion of $p$-values.\n",
    "\n",
    "\n",
    "### $p$-value\n",
    "\n",
    "The $p$-value (or the *probability value*) is the probability that $T(X)$ is at least as extreme as the observed test statistic $T(x)$ assuming that the null hypothesis is *true*, i.e.,\n",
    "\n",
    "$$ p\\text{-value} = P_{H_0}(T(X) \\geq T(x)).$$\n",
    "\n",
    "If the $p$-value is smaller than or equal to a predefined and fixed statistical significance level $\\alpha$, we may reject the null hypothesis. Otherwise, we will conclude that we are lack of evidence to reject the null hypothesis. For a given population distribution, the *region of rejection* will be the interval contained of all the points which has a $p$-value smaller than the statistical significance level $\\alpha$.\n",
    "\n",
    "\n",
    "### One-side Test and Two-sided Test\n",
    "\n",
    "Normally there are two kinds of significance test: the one-sided test and the two-sided test. The *one-sided test* (or *one-tailed test*) is applicable when the null hypothesis and the alternative hypothesis only have one direction. For example, the null hypothesis may state that the true parameter $\\theta$ is less than or equal to a value $c$. The alternative hypothesis would be that $\\theta$ is greater than $c$. That is, the region of rejection is on only one side of the sampling distribution.  Contrary to the one-sided test, the *two-sided test* (or *two-tailed test*) is applicable when the region of rejection is on both sides of the sampling distribution. An example in this case may have a null hypothesis state that the true parameter $\\theta$ is equal to a value $c$. The alternative hypothesis would be that $\\theta$ is not equal to $c$.\n",
    "\n",
    "\n",
    "### General Steps of Hypothesis Testing\n",
    "\n",
    "After getting familiar with the above concepts, let us go through the general steps of hypothesis testing.\n",
    "\n",
    "1. State the question and establish a null hypotheses $H_0$.\n",
    "2. Set the statistical significance level $\\alpha$ and a statistical power ($1 - \\beta$).\n",
    "3. Obtain samples through experiments.  The number of samples needed will depend on the statistical power, and the expected effect size.\n",
    "4. Calculate the test statistic and the $p$-value.\n",
    "5. Make the decision to keep or reject the null hypothesis based on the $p$-value and the statistical significance level $\\alpha$.\n",
    "\n",
    "To conduct a hypothesis test, we start by defining a null hypothesis and a level of risk that we are willing to take. Then we calculate the test statistic of the sample, taking an extreme value of the test statistic as evidence against the null hypothesis. If the test statistic falls within the reject region, we may reject the null hypothesis in favor of the alternative.\n",
    "\n",
    "Hypothesis testing is applicable in a variety of scenarios such as the clinical trails and A/B testing.\n",
    "\n",
    "\n",
    "## Constructing Confidence Intervals\n",
    "\n",
    "\n",
    "When estimating the value of a parameter $\\theta$, point estimators like $\\hat \\theta$ are of limited utility since they contain no notion of uncertainty. Rather, it would be far better if we could produce an interval that would contain the true parameter $\\theta$ with high probability.  If you were interested in such ideas a century ago, then you would have been excited to read \"Outline of a Theory of Statistical Estimation Based on the Classical Theory of Probability\" by Jerzy Neyman :cite:`Neyman.1937`, who first introduced the concept of confidence interval in 1937.\n",
    "\n",
    "To be useful, a confidence interval should be as small as possible for a given degree of certainty. Let us see how to derive it.\n",
    "\n",
    "\n",
    "### Definition\n",
    "\n",
    "Mathematically, a *confidence interval* for the true parameter $\\theta$ is an interval $C_n$ that computed from the sample data such that\n",
    "\n",
    "$$P_{\\theta} (C_n \\ni \\theta) \\geq 1 - \\alpha, \\forall \\theta.$$\n",
    ":eqlabel:`eq_confidence`\n",
    "\n",
    "Here $\\alpha \\in (0, 1)$, and $1 - \\alpha$ is called the *confidence level* or *coverage* of the interval. This is the same $\\alpha$ as the significance level as we discussed about above.\n",
    "\n",
    "Note that :eqref:`eq_confidence` is about variable $C_n$, not about the fixed $\\theta$. To emphasize this, we write $P_{\\theta} (C_n \\ni \\theta)$ rather than $P_{\\theta} (\\theta \\in C_n)$.\n",
    "\n",
    "### Interpretation\n",
    "\n",
    "It is very tempting to interpret a $95\\%$ confidence interval as an interval where you can be $95\\%$ sure the true parameter lies, however this is sadly not true.  The true parameter is fixed, and it is the interval that is random.  Thus a better interpretation would be to say that if you generated a large number of confidence intervals by this procedure, $95\\%$ of the generated intervals would contain the true parameter.\n",
    "\n",
    "This may seem pedantic, but it can have real implications for the interpretation of the results.  In particular, we may satisfy :eqref:`eq_confidence` by constructing intervals that we are *almost certain* do not contain the true value, as long as we only do so rarely enough.  We close this section by providing three tempting but false statements.  An in-depth discussion of these points can be found in :cite:`Morey.Hoekstra.Rouder.ea.2016`.\n",
    "\n",
    "* **Fallacy 1**. Narrow confidence intervals mean we can estimate the parameter precisely.\n",
    "* **Fallacy 2**. The values inside the confidence interval are more likely to be the true value than those outside the interval.\n",
    "* **Fallacy 3**. The probability that a particular observed $95\\%$ confidence interval contains the true value is $95\\%$.\n",
    "\n",
    "Sufficed to say, confidence intervals are subtle objects.  However, if you keep the interpretation clear, they can be powerful tools.\n",
    "\n",
    "### A Gaussian Example\n",
    "\n",
    "Let us discuss the most classical example, the confidence interval for the mean of a Gaussian of unknown mean and variance.  Suppose we collect $n$ samples $\\{x_i\\}_{i=1}^n$ from our Gaussian $\\mathcal{N}(\\mu, \\sigma^2)$.  We can compute estimators for the mean and standard deviation by taking\n",
    "\n",
    "$$\\hat\\mu_n = \\frac{1}{n}\\sum_{i=1}^n x_i \\;\\text{and}\\; \\hat\\sigma^2_n = \\frac{1}{n-1}\\sum_{i=1}^n (x_i - \\hat\\mu)^2.$$\n",
    "\n",
    "If we now consider the random variable\n",
    "\n",
    "$$\n",
    "T = \\frac{\\hat\\mu_n - \\mu}{\\hat\\sigma_n/\\sqrt{n}},\n",
    "$$\n",
    "\n",
    "we obtain a random variable following a well-known distribution called the *Student's t-distribution on* $n-1$ *degrees of freedom*.\n",
    "\n",
    "This distribution is very well studied, and it is known, for instance, that as $n\\rightarrow \\infty$, it is approximately a standard Gaussian, and thus by looking up values of the Gaussian c.d.f. in a table, we may conclude that the value of $T$ is in the interval $[-1.96, 1.96]$ at least $95\\%$ of the time.  For finite values of $n$, the interval needs to be somewhat larger, but are well known and precomputed in tables.\n",
    "\n",
    "Thus, we may conclude that for large $n$,\n",
    "\n",
    "$$\n",
    "P\\left(\\frac{\\hat\\mu_n - \\mu}{\\hat\\sigma_n/\\sqrt{n}} \\in [-1.96, 1.96]\\right) \\ge 0.95.\n",
    "$$\n",
    "\n",
    "Rearranging this by multiplying both sides by $\\hat\\sigma_n/\\sqrt{n}$ and then adding $\\hat\\mu_n$, we obtain\n",
    "\n",
    "$$\n",
    "P\\left(\\mu \\in \\left[\\hat\\mu_n - 1.96\\frac{\\hat\\sigma_n}{\\sqrt{n}}, \\hat\\mu_n + 1.96\\frac{\\hat\\sigma_n}{\\sqrt{n}}\\right]\\right) \\ge 0.95.\n",
    "$$\n",
    "\n",
    "Thus we know that we have found our $95\\%$ confidence interval:\n",
    "$$\\left[\\hat\\mu_n - 1.96\\frac{\\hat\\sigma_n}{\\sqrt{n}}, \\hat\\mu_n + 1.96\\frac{\\hat\\sigma_n}{\\sqrt{n}}\\right].$$\n",
    ":eqlabel:`eq_gauss_confidence`\n",
    "\n",
    "It is safe to say that :eqref:`eq_gauss_confidence` is one of the most used formula in statistics.  Let us close our discussion of statistics by implementing it.  For simplicity, we assume we are in the asymptotic regime.  Small values of $N$ should include the correct value of `t_star` obtained either programmatically or from a $t$-table.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "origin_pos": 21,
    "tab": [
     "tensorflow"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(<tf.Tensor: shape=(), dtype=float32, numpy=-0.07934592>,\n",
       " <tf.Tensor: shape=(), dtype=float32, numpy=0.043209106>)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Number of samples\n",
    "N = 1000\n",
    "\n",
    "# Sample dataset\n",
    "samples = tf.random.normal((N,), 0, 1)\n",
    "\n",
    "# Lookup Students's t-distribution c.d.f.\n",
    "t_star = 1.96\n",
    "\n",
    "# Construct interval\n",
    "mu_hat = tf.reduce_mean(samples)\n",
    "sigma_hat = tf.math.reduce_std(samples)\n",
    "(mu_hat - t_star*sigma_hat/tf.sqrt(tf.constant(N, dtype=tf.float32)), \\\n",
    " mu_hat + t_star*sigma_hat/tf.sqrt(tf.constant(N, dtype=tf.float32)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 22
   },
   "source": [
    "## Summary\n",
    "\n",
    "* Statistics focuses on inference problems, whereas deep learning emphasizes on making accurate predictions without explicitly programming and understanding.\n",
    "* There are three common statistics inference methods: evaluating and comparing estimators, conducting hypothesis tests, and constructing confidence intervals.\n",
    "* There are three most common estimators: statistical bias, standard deviation, and mean square error.\n",
    "* A confidence interval is an estimated range of a true population parameter that we can construct by given the samples.\n",
    "* Hypothesis testing is a way of evaluating some evidence against the default statement about a population.\n",
    "\n",
    "\n",
    "## Exercises\n",
    "\n",
    "1. Let $X_1, X_2, \\ldots, X_n \\overset{\\text{iid}}{\\sim} \\mathrm{Unif}(0, \\theta)$, where \"iid\" stands for *independent and identically distributed*. Consider the following estimators of $\\theta$:\n",
    "$$\\hat{\\theta} = \\max \\{X_1, X_2, \\ldots, X_n \\};$$\n",
    "$$\\tilde{\\theta} = 2 \\bar{X_n} = \\frac{2}{n} \\sum_{i=1}^n X_i.$$\n",
    "    * Find the statistical bias, standard deviation, and mean square error of $\\hat{\\theta}.$\n",
    "    * Find the statistical bias, standard deviation, and mean square error of $\\tilde{\\theta}.$\n",
    "    * Which estimator is better?\n",
    "1. For our chemist example in introduction, can you derive the 5 steps to conduct a two-sided hypothesis testing? Given the statistical significance level $\\alpha = 0.05$ and the statistical power $1 - \\beta = 0.8$.\n",
    "1. Run the confidence interval code with $N=2$ and $\\alpha = 0.5$ for $100$ independently generated dataset, and plot the resulting intervals (in this case `t_star = 1.0`).  You will see several very short intervals which are very far from containing the true mean $0$.  Does this contradict the interpretation of the confidence interval?  Do you feel comfortable using short intervals to indicate high precision estimates?\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "origin_pos": 25,
    "tab": [
     "tensorflow"
    ]
   },
   "source": [
    "[Discussions](https://discuss.d2l.ai/t/1103)\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}