{ "info": { "author": "Simon Reinhardt", "author_email": "simon.reinhardt@physik.uni-regensburg.de", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "curve_fit.annealing\n===============================\n\nMost curve fitting algorithms rely on local optimization routines. These demand good estimates of the fit parameters.\n\nInstead, this module allows to use **global optimization** routines of\nscipy.optimize_ to minimize the squared deviation function.\n\nInstallation\n------------------------\n\nThis module can be installed from PyPI ::\n\n pip3 install curve_fit.annealing\n\nExample\n---------------\n\nLet us fit a beat signal with two sinus functions, with a total of 6 free parameters.\n\nBy default, the ``curve_fit`` function of this module will use the scipy.optimize.dual_annealing_ method to find the global optimum of the curve fitting problem. The dual annealing algorithm requires bounds for the fitting parameters.\nOther global optimization methods like scipy.optimize.basinhopping_ require an initial guess of the parameters instead.\n\n\n::\n\n import numpy as np\n from matplotlib import pyplot as plt\n from curve_fit import annealing\n\n def f(x,p):\n # Sum of two sinus functions\n return p[0]*np.sin(p[1]*x + p[2]) + p[3]*np.sin(p[4]*x+p[5])\n\n\n xdata = np.linspace(-100,100,1000)\n ydata = f(xdata, [1, 1, 0, 1, 0.9, 0])\n\n plt.plot(xdata, ydata, label='data')\n bounds=[[0,2],[0,2],[0,2*np.pi],[0,2],[0,2],[0,2*np.pi]]\n\n result = annealing.curve_fit(f, xdata, ydata, bounds=bounds)\n\n p_opt = result.x # optimal fit parameters\n ydata_res = f(xdata, p_opt)\n plt.plot(xdata, ydata_res, label='fit')\n plt.legend()\n plt.grid()\n\n plt.show()\n\n\nOr use scipy.optimize.basinhopping_ ::\n\n result = annealing.curve_fit(f, xdata, ydata, method='basinhopping', x0=np.zeros(6))\n\n\nAPI\n-----\n\n``curve_fit(f, xdata, ydata, [method='dual_annealing', args, kwargs])``\n\nFit function ``f`` to data with selectable optimization method\nfrom ``scipy.optimize``.\n\nParameters:\n f: callable\n The model function, ``f(xdata, p)``. The second argument holds the\n fitting parameters.\n xdata : array_like or object\n The independent variable where the data is measured.\n Should usually be an M-length sequence or an (k,M)-shaped array for\n functions with k predictors, but can actually be any object.\n ydata : array_like\n The dependent data, a length M array - nominally ``f(xdata, ...)``.\n method : str\n scipy.optimize method to use for non-linear least squares minimization.\n Default is 'dual_annealing'.\n args, kwargs : tuple and dict, optional\n Additional arguments passed to the optimization method.\n\nReturns:\n Return ``OptimizeResult`` object. The ``x`` attribute holds the fitting\n parameters. \n\n\n.. _scipy.optimize: https://docs.scipy.org/doc/scipy/reference/optimize.html\n.. _scipy.optimize.dual_annealing: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.dual_annealing.html#scipy.optimize.dual_annealing\n.. _scipy.optimize.basinhopping: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.basinhopping.html#scipy.optimize.basinhopping\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/amba/curve_fit.annealing", "keywords": "curve fitting global optimization simulated annealing", "license": "", "maintainer": "", "maintainer_email": "", "name": "curve-fit.annealing", "package_url": "https://pypi.org/project/curve-fit.annealing/", "platform": "", "project_url": "https://pypi.org/project/curve-fit.annealing/", "project_urls": { "Homepage": "https://github.com/amba/curve_fit.annealing" }, "release_url": "https://pypi.org/project/curve-fit.annealing/0.0.3/", "requires_dist": [ "scipy (>=1.2.0)" ], "requires_python": ">=3.5", "summary": "Curve fitting with global optimization routines", "version": "0.0.3" }, "last_serial": 5825328, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "53902e35ed3b2498450cb437a99a196d", "sha256": "1a3fd765f301b756522c5e29e5071f6ab5b8251329a31c711dbdf3f7d4f2e416" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "53902e35ed3b2498450cb437a99a196d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 4796, "upload_time": "2019-09-09T13:24:51", "url": "https://files.pythonhosted.org/packages/48/ef/1b7d6ae6f4173c251401fc7d4d662880f8844ca59e7c6228ef434c47e7a8/curve_fit.annealing-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ff61079cd689c5d6b79e55eb0059ea86", "sha256": "c629fba3efdc77880c92f8cd3169e8906d8f41d02dd592ac33064a052d30c1b6" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.1.tar.gz", "has_sig": false, "md5_digest": "ff61079cd689c5d6b79e55eb0059ea86", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 2683, "upload_time": "2019-09-09T13:24:53", "url": "https://files.pythonhosted.org/packages/0c/d9/6b202bc0fba4751d251f458e3ec0697abe5b7d6e13458f18d0df0178e495/curve_fit.annealing-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "35c67be60d08a90ef771756aabddcfff", "sha256": "73e8cd870ffcd05d0201c3d6987aeb25d7777efb6204b845f24455ca0c35aa20" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "35c67be60d08a90ef771756aabddcfff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 3842, "upload_time": "2019-09-13T12:11:19", "url": "https://files.pythonhosted.org/packages/d0/d2/363c2f82ca926e8eb3a85a64558f95dd4b77dff1b77de826cdc90cd1b51d/curve_fit.annealing-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5b94c7bae312afdb4c53c877a44f4977", "sha256": "907f42ed43698b08ec4c834f75618fb628582d9a6bad5f6f2098e9f00d8aacdf" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.2.tar.gz", "has_sig": false, "md5_digest": "5b94c7bae312afdb4c53c877a44f4977", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 2763, "upload_time": "2019-09-13T12:11:20", "url": "https://files.pythonhosted.org/packages/fc/8c/96ee8d0c06e14f1e5bf83058bc0a736ecc6fa072cde38522bfbbf4491b5e/curve_fit.annealing-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "2408c8ade0dc6db10b976cdf5275d29e", "sha256": "891d71d22b5e420a19e0e13442243627c5ec9599f03727fc852c14226a16505d" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "2408c8ade0dc6db10b976cdf5275d29e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 3795, "upload_time": "2019-09-13T12:30:09", "url": "https://files.pythonhosted.org/packages/06/55/4d170342aa219342ad97dc63e804abb85eb718191a4070f166bb3be26cec/curve_fit.annealing-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5182efc08edf1ab52802e1a866fe264b", "sha256": "d9bbb9db7f89c98717db0434547f7d98d343cece3e2697f91eee4fcbe0923a78" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5182efc08edf1ab52802e1a866fe264b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 2717, "upload_time": "2019-09-13T12:30:10", "url": "https://files.pythonhosted.org/packages/73/20/c52a733ced5a83fd8f57ba36ed64d0518e7e119f845e15b87aa34c02dc47/curve_fit.annealing-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2408c8ade0dc6db10b976cdf5275d29e", "sha256": "891d71d22b5e420a19e0e13442243627c5ec9599f03727fc852c14226a16505d" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "2408c8ade0dc6db10b976cdf5275d29e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 3795, "upload_time": "2019-09-13T12:30:09", "url": "https://files.pythonhosted.org/packages/06/55/4d170342aa219342ad97dc63e804abb85eb718191a4070f166bb3be26cec/curve_fit.annealing-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5182efc08edf1ab52802e1a866fe264b", "sha256": "d9bbb9db7f89c98717db0434547f7d98d343cece3e2697f91eee4fcbe0923a78" }, "downloads": -1, "filename": "curve_fit.annealing-0.0.3.tar.gz", "has_sig": false, "md5_digest": "5182efc08edf1ab52802e1a866fe264b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 2717, "upload_time": "2019-09-13T12:30:10", "url": "https://files.pythonhosted.org/packages/73/20/c52a733ced5a83fd8f57ba36ed64d0518e7e119f845e15b87aa34c02dc47/curve_fit.annealing-0.0.3.tar.gz" } ] }