{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Automatic fit function" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from smpl import plot\n", "from smpl import stat\n", "from smpl import io\n", "from smpl import functions as f\n", "import uncertainties.unumpy as unp\n", "import smpl\n", "smpl.__version__" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for n in ['test_linear_data.txt', 'test_quad_data.txt']:\n", " data = np.loadtxt(io.find_file(n,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)\n", "\n", "\n", " function,fitparams,lfunc = plot.auto(xdata, ydata, fmt='.', label='data', xaxis=\"x in a.u.\",yaxis=\"y in a.u.\",sigmas=1,epsfcn=0.00001,maxfev=1000000,init=True)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "x= np.linspace(-5,5,100)\n", "y = stat.noisy(np.exp(2*x))\n", "ff = plot.auto(x, y, fmt='.', label='data', xaxis=\"x in a.u.\",yaxis=\"y in a.u.\",sigmas=1)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "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 }