Name | jacobi JSON |
Version |
0.9.2
JSON |
| download |
home_page | |
Summary | Compute numerical derivatives |
upload_time | 2023-08-16 14:48:53 |
maintainer | |
docs_url | None |
author | Hans Dembinski |
requires_python | >=3.8 |
license | Copyright 2020 Hans Dembinski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
.. |jacobi| image:: https://hdembinski.github.io/jacobi/_images/logo.svg
:alt: jacobi
|jacobi|
========
.. image:: https://img.shields.io/pypi/v/jacobi
:target: https://pypi.org/project/jacobi
.. image:: https://img.shields.io/badge/github-docs-success
:target: https://hdembinski.github.io/jacobi
.. image:: https://img.shields.io/badge/github-source-blue
:target: https://github.com/HDembinski/jacobi
.. image:: https://zenodo.org/badge/270612858.svg
:target: https://zenodo.org/badge/latestdoi/270612858
Fast numerical derivatives for analytic functions with arbitrary round-off error and error propagation.
`Click here for full documentation <https://hdembinski.github.io/jacobi>`_.
Features
--------
- Robustly compute the generalised Jacobi matrix for an arbitrary real analytic mapping ℝⁿ → ℝⁱ¹ × ... × ℝⁱⁿ
- Derivative is either computed to specified accuracy (to save computing time) or until maximum precision of function is reached
- Algorithm based on John D'Errico's `DERIVEST <https://de.mathworks.com/matlabcentral/fileexchange/13490-adaptive-robust-numerical-differentiation>`_: works even with functions that have large round-off error
- Up to 1000x faster than `numdifftools <https://pypi.org/project/numdifftools>`_ at equivalent precision
- Returns error estimates for derivatives
- Supports arbitrary auxiliary function arguments
- Perform statistical error propagation based on numerically computed jacobian
- Lightweight package, only depends on numpy
Planned features
----------------
- Compute the Hessian matrix numerically with the same algorithm
- Further generalize the calculation to support function arguments with shape (N, K), in that case compute the Jacobi matrix for each of the K vectors of length N
Examples
--------
.. code-block:: python
from matplotlib import pyplot as plt
import numpy as np
from jacobi import jacobi
# function of one variable with auxiliary argument; returns a vector
def f(x):
return np.sin(x) / x
x = np.linspace(-10, 10, 200)
fx = f(x)
# f(x) is a simple vectorized function, jacobian is diagonal
fdx, fdxe = jacobi(f, x, diagonal=True)
# fdxe is uncertainty estimate for derivative
plt.plot(x, fx, color="k", label="$f(x) = sin(x) / x$")
plt.plot(x, fdx, label="$f'(x)$ computed with jacobi")
scale = 14
plt.fill_between(
x,
fdx - fdxe * 10**scale,
fdx + fdxe * 10**scale,
label=f"$f'(x)$ error estimate$\\times \\, 10^{{{scale}}}$",
facecolor="C0",
alpha=0.5,
)
plt.legend()
.. image:: https://hdembinski.github.io/jacobi/_images/example.svg
.. code-block:: python
from jacobi import propagate
import numpy as np
from scipy.special import gamma
# arbitrarily complex function that calls compiled libraries, numba-jitted code, etc.
def fn(x):
r = np.empty(3)
r[0] = 1.5 * np.exp(-x[0] ** 2)
r[1] = gamma(x[1] ** 3.1)
r[2] = np.polyval([1, 2, 3], x[0])
return r # x and r have different lengths
# fn accepts a parameter vector x, which has an associated covariance matrix xcov
x = [1.0, 2.0]
xcov = [[1.1, 0.1], [0.1, 2.3]]
y, ycov = propagate(fn, x, xcov) # y=f(x) and ycov = J xcov J^T
Comparison to numdifftools
--------------------------
Speed
^^^^^
Jacobi makes better use of vectorized computation than numdifftools and converges rapidly if the derivative is trivial. This leads to a dramatic speedup in some cases.
Smaller run-time is better (and ratio > 1).
.. image:: https://hdembinski.github.io/jacobi/_images/speed.svg
Precision
^^^^^^^^^
The machine precision is indicated by the dashed line. Jacobi is comparable in accuracy to numdifftools. The error estimate has the right order of magnitude but slightly underestimates the true deviation. This does not matter for most applications.
.. image:: https://hdembinski.github.io/jacobi/_images/precision.svg
Raw data
{
"_id": null,
"home_page": "",
"name": "jacobi",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Hans Dembinski",
"author_email": "hans.dembinski@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6a/e5/d851f71f1d7fa52212364242f763d1ef15c314beaa2761b5d0f0c88e40a1/jacobi-0.9.2.tar.gz",
"platform": null,
"description": ".. |jacobi| image:: https://hdembinski.github.io/jacobi/_images/logo.svg\n :alt: jacobi\n\n|jacobi|\n========\n\n.. image:: https://img.shields.io/pypi/v/jacobi\n :target: https://pypi.org/project/jacobi\n.. image:: https://img.shields.io/badge/github-docs-success\n :target: https://hdembinski.github.io/jacobi\n.. image:: https://img.shields.io/badge/github-source-blue\n :target: https://github.com/HDembinski/jacobi\n.. image:: https://zenodo.org/badge/270612858.svg\n :target: https://zenodo.org/badge/latestdoi/270612858\n\nFast numerical derivatives for analytic functions with arbitrary round-off error and error propagation.\n\n`Click here for full documentation <https://hdembinski.github.io/jacobi>`_.\n\nFeatures\n--------\n\n- Robustly compute the generalised Jacobi matrix for an arbitrary real analytic mapping \u211d\u207f \u2192 \u211d\u2071\u00b9 \u00d7 ... \u00d7 \u211d\u2071\u207f\n- Derivative is either computed to specified accuracy (to save computing time) or until maximum precision of function is reached\n- Algorithm based on John D'Errico's `DERIVEST <https://de.mathworks.com/matlabcentral/fileexchange/13490-adaptive-robust-numerical-differentiation>`_: works even with functions that have large round-off error\n- Up to 1000x faster than `numdifftools <https://pypi.org/project/numdifftools>`_ at equivalent precision\n- Returns error estimates for derivatives\n- Supports arbitrary auxiliary function arguments\n- Perform statistical error propagation based on numerically computed jacobian\n- Lightweight package, only depends on numpy\n\nPlanned features\n----------------\n\n- Compute the Hessian matrix numerically with the same algorithm\n- Further generalize the calculation to support function arguments with shape (N, K), in that case compute the Jacobi matrix for each of the K vectors of length N\n\nExamples\n--------\n\n.. code-block:: python\n\n from matplotlib import pyplot as plt\n import numpy as np\n from jacobi import jacobi\n\n\n # function of one variable with auxiliary argument; returns a vector\n def f(x):\n return np.sin(x) / x\n\n\n x = np.linspace(-10, 10, 200)\n fx = f(x)\n\n # f(x) is a simple vectorized function, jacobian is diagonal\n fdx, fdxe = jacobi(f, x, diagonal=True)\n # fdxe is uncertainty estimate for derivative\n\n plt.plot(x, fx, color=\"k\", label=\"$f(x) = sin(x) / x$\")\n plt.plot(x, fdx, label=\"$f'(x)$ computed with jacobi\")\n scale = 14\n plt.fill_between(\n x,\n fdx - fdxe * 10**scale,\n fdx + fdxe * 10**scale,\n label=f\"$f'(x)$ error estimate$\\\\times \\\\, 10^{{{scale}}}$\",\n facecolor=\"C0\",\n alpha=0.5,\n )\n plt.legend()\n\n.. image:: https://hdembinski.github.io/jacobi/_images/example.svg\n\n.. code-block:: python\n\n from jacobi import propagate\n import numpy as np\n from scipy.special import gamma\n\n\n # arbitrarily complex function that calls compiled libraries, numba-jitted code, etc.\n def fn(x):\n r = np.empty(3)\n r[0] = 1.5 * np.exp(-x[0] ** 2)\n r[1] = gamma(x[1] ** 3.1)\n r[2] = np.polyval([1, 2, 3], x[0])\n return r # x and r have different lengths\n\n # fn accepts a parameter vector x, which has an associated covariance matrix xcov\n x = [1.0, 2.0]\n xcov = [[1.1, 0.1], [0.1, 2.3]]\n y, ycov = propagate(fn, x, xcov) # y=f(x) and ycov = J xcov J^T\n\n\nComparison to numdifftools\n--------------------------\n\nSpeed\n^^^^^\n\nJacobi makes better use of vectorized computation than numdifftools and converges rapidly if the derivative is trivial. This leads to a dramatic speedup in some cases.\n\nSmaller run-time is better (and ratio > 1).\n\n.. image:: https://hdembinski.github.io/jacobi/_images/speed.svg\n\nPrecision\n^^^^^^^^^\n\nThe machine precision is indicated by the dashed line. Jacobi is comparable in accuracy to numdifftools. The error estimate has the right order of magnitude but slightly underestimates the true deviation. This does not matter for most applications.\n\n.. image:: https://hdembinski.github.io/jacobi/_images/precision.svg\n",
"bugtrack_url": null,
"license": "Copyright 2020 Hans Dembinski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Compute numerical derivatives",
"version": "0.9.2",
"project_urls": {
"documentation": "https://hdembinski.github.io/jacobi/",
"repository": "https://github.com/hdembinski/jacobi"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b05c2d6a44da539db44820b1c053958bfc4ee011e33f4f110175bfc712520440",
"md5": "4963d920921e1a6ac2785930e2fb6677",
"sha256": "7e57b2d9c62d47bce688ef4b3564adeb1def611cf5ed232ec39a6aa6083f7a8c"
},
"downloads": -1,
"filename": "jacobi-0.9.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4963d920921e1a6ac2785930e2fb6677",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11784,
"upload_time": "2023-08-16T14:48:52",
"upload_time_iso_8601": "2023-08-16T14:48:52.041064Z",
"url": "https://files.pythonhosted.org/packages/b0/5c/2d6a44da539db44820b1c053958bfc4ee011e33f4f110175bfc712520440/jacobi-0.9.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6ae5d851f71f1d7fa52212364242f763d1ef15c314beaa2761b5d0f0c88e40a1",
"md5": "0525b2276da491eb7a22c12700cf3991",
"sha256": "c11f481663246ef1c2da915b9f9ab4ef229051fb14e0afc232d4668301320828"
},
"downloads": -1,
"filename": "jacobi-0.9.2.tar.gz",
"has_sig": false,
"md5_digest": "0525b2276da491eb7a22c12700cf3991",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 998268,
"upload_time": "2023-08-16T14:48:53",
"upload_time_iso_8601": "2023-08-16T14:48:53.305410Z",
"url": "https://files.pythonhosted.org/packages/6a/e5/d851f71f1d7fa52212364242f763d1ef15c314beaa2761b5d0f0c88e40a1/jacobi-0.9.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-16 14:48:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "hdembinski",
"github_project": "jacobi",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jacobi"
}