Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goessl/multipoly
A multivariate polynomial module.
https://github.com/goessl/multipoly
easy lightweight multivariate multivariate-polynomials multivariate-regression numpy pip pip3 polynomial polynomial-regression polynomials pypi python python3
Last synced: 1 day ago
JSON representation
A multivariate polynomial module.
- Host: GitHub
- URL: https://github.com/goessl/multipoly
- Owner: goessl
- License: mit
- Created: 2023-10-28T10:01:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-10T15:31:45.000Z (about 1 year ago)
- Last Synced: 2024-10-12T16:40:57.320Z (about 1 month ago)
- Topics: easy, lightweight, multivariate, multivariate-polynomials, multivariate-regression, numpy, pip, pip3, polynomial, polynomial-regression, polynomials, pypi, python, python3
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# multipoly
A multivariate polynomial module.
This package provides a single class, `MultiPoly`, to handle multivariate polynomials of form
$$
p(\vec{x}) = \sum_{0\leq n\leq\deg(p)}a_n(\vec{x}-\vec{c})^n = \sum_{n_0=0}^{\deg_0(p)}\cdots\sum_{n_{\dim(p)-1}=0}^{\deg_{\dim(p)-1}(p)}a_{n_0\cdots n_{\dim(p)-1}}(x_0-c_0)^{n_0}\cdots(x_{\dim(p)-1}-c_{\dim(p)-1})^{n_{\dim(p)-1}}
$$where $n$ and $\deg(p)$ are multi-indices.
This differs from the usual upper sum limit $|n|\leq\deg(p)$ where $n$ is a multi-index and $\deg(p)$ a natural number,
because this way the degree in every variable can be controlled individually.## Installation
```
pip install multipoly
```## Usage
A polynomial can be initialized in two ways:
- With the constructor `Multipoly(a, c=None)`, that takes the coefficients and optional offsets.
The coefficients are of shape `deg`, that is a tuple with the degree for every variable.
- By fitting data with `Multipoly.fit(X, y, deg, c=None)`.`MultiPoly` objects have
- a dimension `dim`, the number of variables &
- a degree `deg`, the degrees in its variables.They can
- be called on a single datapoint `p(x, y, ...)` or on multiple datapoints in a 2D `numpy.array`,
- rounded `p.round(decimals=0)`, to round coefficients `a` and offsets `c` &
- be converted to strings with `toString(symbols=None)`, where the symbols for its variables can be specified
(`__str__` defaults to `x0, x1, ...`).## License (MIT)
Copyright (c) 2023 Sebastian Gössl
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.