{ "info": { "author": "Michael Woods", "author_email": "physicsmichael@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Scientific/Engineering", "Topic :: Utilities" ], "description": "python-fit\r\n==========\r\n\r\n.. image:: https://pypip.in/download/python-fit/badge.png\r\n :target: https://pypi.python.org/pypi/python-fit/\r\n :alt: Downloads\r\n.. image:: https://pypip.in/version/python-fit/badge.png\r\n :target: https://pypi.python.org/pypi/python-fit/\r\n :alt: Latest Version\r\n\r\nThe python-fit module is designed for people who need to fit data\r\nfrequently and quickly. The module is not designed for huge amounts of\r\ncontrol over the minimization process but rather tries to make fitting\r\ndata simple and painless. If you want to fit data several times a day,\r\nevery day, and you really just want to see if the fit you've made looks\r\ngood against your data, check out this software. If you want one very\r\nstatistically aware and neurotically controlled fit, you might consider\r\nlooking elsewhere (give zunzun_ a look).\r\n\r\n.. _zunzun: http://www.zunzun.com/\r\n\r\nWith python-fit, you get work done.\r\n\r\nFeatures\r\n--------\r\n\r\n- Common fitting curves built-in\r\n- Default parameters for built-in functions intelligently calculated\r\n using your data.\r\n- Fit with user defined functions, too.\r\n- A ready-to-plot-fit always conviently returned.\r\n- Get fit parameters and associated errors.\r\n- Chi-squared residual.\r\n\r\nExample Usage\r\n-------------\r\n\r\nFit with built in functions:\r\n\r\n.. code-block:: python\r\n\r\n from pylab import *\r\n ion()\r\n import fit\r\n from numpy import random, exp\r\n random.seed(0)\r\n\r\n # Create some data to fit\r\n x = arange(-10, 10, .2)\r\n # A gaussian of height 10, width 2, centered at zero. With noise.\r\n y = 10*exp(-x**2/8) + (random.rand(100) - 0.5)\r\n\r\n\r\n # No need to provide first guess at parameters for fit.gaus\r\n (xf, yf), params, err, chi = fit.fit(fit.gaus, x,y)\r\n\r\n print \"N: %.2f +/- %.3f\" % (params[0], err[0])\r\n print \"N: %.2f +/- %.3f\" % (params[1], err[1])\r\n print \"N: %.2f +/- %.3f\" % (params[2], err[2])\r\n\r\n plot(x,y, 'bo', label='Data')\r\n plot(xf, yf, 'r-', label='Fit')\r\n legend() \r\n\r\nFunctions available:\r\n\r\n.. code-block:: python\r\n\r\n Gaussian curve\r\n Exponential curve\r\n Double exponential\r\n Polynomials for degrees 0-20\r\n Power-Law\r\n Crystal Ball\r\n ... and more!\r\n\r\nFit with user defined functions:\r\n\r\n.. code-block:: python\r\n\r\n x = (4.2105303, 5.2631601, 6.2405997, 7.5187997, 8.7218, 9.7744402, 10.676691, 11.65414, 12.63158, 13.83459, 14.887219, 16.015039, 17.06767, \r\n 18.270679, 19.24812, 20.300751, 21.50376, 23.157888, 25.789471, 28.345871, 30.601501, 33.458643, 39.022559, 46.015039, 48.270679)\r\n y = (0.18942001, 0.2099, 0.23891001, 0.27816002, 0.31911, 0.35836001, 0.39932001, 0.43686003, 0.46416002, 0.49829001, 0.51536004, 0.52556, 0.51876995, \r\n 0.5, 0.47271, 0.44026, 0.39249001, 0.33106002, 0.24060, 0.17746, 0.13311001, 0.11262, 0.095566, 0.095566, 0.095566)\r\n\r\n x = array(x)\r\n y = array(y)\r\n\r\n # Guassian with quadratic background.\r\n def example_function(params, x):\r\n N,mu,sigma,a,b,c = params\r\n return N*exp(-0.5 * ((x-mu)/sigma)**2 ) + a*x**2 + b*x + c\r\n \r\n # It will still try to guess parameters, but they are dumb!\r\n (xf,yf),p,e,chi = fit.fit(example_function, x,y)\r\n plot(x,y, 'bo', label='Data')\r\n plot(xf,yf, 'r-', label='Fit')\r\n legend()\r\n\r\nEven though ``example_function`` is defined by the user, python-fit will\r\nguess parameters (the median value of the xdata for all parameters; it\r\nworks if x and y are on similar scales). If the fit fails, then provide\r\nsome decent parameters as a first guess:\r\n\r\n.. code-block:: python\r\n\r\n results = fit.fit(example_function, x, y, default_pars = [1, 12, 10, 1, 1, 1])\r\n plot(results[0][0], results[0][1], 'r--')\r\n\r\nFit a sub-range:\r\n\r\n.. code-block:: python\r\n\r\n clf()\r\n results = fit.fit(fit.gaus, x, y, data_range=[0, 23])\r\n plot(results[0][0], results[0][1], 'r-.')\r\n\r\nDefine your own weights to prevent outliers from wreaking havoc on your\r\nfit:\r\n\r\n.. code-block:: python\r\n\r\n # Create some outliers.\r\n y_outlier = y + (random.rand(len(y))**20)*3\r\n # I'll just make a cut and say outliers are above 0.55\r\n weights = 1. * (y_outlier < .55)\r\n results = fit.fit(example_function, x, y_outlier, we=weights)\r\n clf()\r\n plot(x,y_outlier, 'bo', label='Data w/ Outliers')\r\n plot(results[0][0], results[0][1], 'r-.', label='Fit around outliers')", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/vgm64/python-fit", "keywords": "fitting curve", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-fit", "package_url": "https://pypi.org/project/python-fit/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/python-fit/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/vgm64/python-fit" }, "release_url": "https://pypi.org/project/python-fit/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "A python module using scipy's orthogonal distance regression that makes fitting data easy.", "version": "1.0.0" }, "last_serial": 1108973, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "9040ba1ec0dce3436dcb80a78a7cb4e9", "sha256": "10d235bcff69a7331c0cd929bcc6254575f03b4c74caff4ab73eb7b65295d814" }, "downloads": -1, "filename": "python-fit-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9040ba1ec0dce3436dcb80a78a7cb4e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6576, "upload_time": "2014-05-27T22:47:09", "url": "https://files.pythonhosted.org/packages/f1/b0/705b56e10568bd2f8d1a19889a16b3ce132af3811ed339af9f528ac357a0/python-fit-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9040ba1ec0dce3436dcb80a78a7cb4e9", "sha256": "10d235bcff69a7331c0cd929bcc6254575f03b4c74caff4ab73eb7b65295d814" }, "downloads": -1, "filename": "python-fit-1.0.0.tar.gz", "has_sig": false, "md5_digest": "9040ba1ec0dce3436dcb80a78a7cb4e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6576, "upload_time": "2014-05-27T22:47:09", "url": "https://files.pythonhosted.org/packages/f1/b0/705b56e10568bd2f8d1a19889a16b3ce132af3811ed339af9f528ac357a0/python-fit-1.0.0.tar.gz" } ] }