{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Uncertainties" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import smpl\n", "from smpl import plot\n", "from smpl import io\n", "from smpl import functions as f\n", "import numpy as np\n", "np.random.seed(1337)\n", "print(smpl.__version__)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import uncertainties.unumpy as unp\n", "data = np.loadtxt(io.find_file('test_linear_data.txt',3))\n", "xdata = data[:,0]\n", "xerr = data[:,2]\n", "ydata = data[:,1]\n", "yerr = data[:,3]\n", "x = unp.uarray(xdata,xerr)\n", "y = unp.uarray(ydata,yerr)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.data(x,y,label=\"data\",fmt=None)\n", "plot.data(x,y,label=\"data\",fmt=\"step\",init=True)\n", "plot.data(x,y,label=\"data\",fmt=\"hist\",init=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.data(plot.unv(x),plot.unv(y),label=\"data\",fmt=\"hist\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x= np.random.randn(1000)\n", "print(isinstance(x, (list, tuple, np.ndarray)))\n", "plot.data(x,bins=20,label=\"data\",fmt=None)\n", "plot.data(x,bins=20,label=\"data\",fmt=\"step\",init=True)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Visually increased uncertainties by the scaling given by data_sigmas." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.data(x,bins=20,data_sigmas=5,label=\"data\",fmt=None)\n", "plot.data(x,bins=20,data_sigmas=5,label=\"data\",fmt=\"step\",init=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.15" } }, "nbformat": 4, "nbformat_minor": 4 }