Skip to main content

Python library for multivariate polynomial interpolation.

Project description

Code style: black

minterpy

to minterpy *sth.* (transitive verb) -- to produce a multivariate polynomial representation of *sth.* .
— The minterpy developers in ["Lifting the curse of dimensionality"](https://interpol.pages.hzdr.de/minterpy/fundamentals/introduction.html)

minterpy is an open-source Python package for a multivariate generalization of the classical Newton and Lagrange interpolation schemes as well as related tasks. It is based on an optimized re-implementation of the multivariate interpolation prototype algorithm (MIP) by Hecht et al.^1 and thereby provides software solutions that lift the curse of dimensionality from interpolation tasks. While interpolation occurs as the bottleneck of most computational challenges, minterpy aims to free empirical sciences from their computational limitations.

minterpy is continuously extended and improved by adding further functionality and modules that provide novel digital solutions to a broad field of computational challenges, including but not limited to:

  • multivariate interpolation
  • non-linear polynomial regression
  • numerical integration
  • global (black-box) optimization
  • surface level-set methods
  • non-periodic spectral partial differential equations (PDE) solvers on flat and complex geometries
  • machine learning regularization
  • data reconstruction
  • computational solutions in algebraic geometry

Installation

Since this implementation is a prototype, we currently only provide the installation by self-building from source. We recommend to using git to get the minterpy source:

git clone https://gitlab.hzdr.de/interpol/minterpy.git

Within the source directory, you may use the following package manager to install minterpy.

A best practice is to create a virtual environment for minterpy. You can do this with the help of conda and the environment.yaml by:

conda env create -f environment.yaml

A new conda environment called minterpy is created. Activate the new environment by:

conda activate minterpy

From within the environment, install the minterpy using pip,

pip install [-e] .[all,dev,docs]

where the flag -e means the package is directly linked into the python site-packages of your Python version. The options [all,dev,docs] refer to the requirements defined in the options.extras_require section in setup.cfg.

You must not use the command python setup.py install to install minterpy, as you cannot always assume the files setup.py will always be present in the further development of minterpy.

Finally, if you want to deactivate the conda environment, type:

conda deactivate

Alternative to conda, you can create a new virtual environment via venv, virtualenv, or pyenv-virtualenv. See CONTRIBUTING.md for details.

Quickstart

With minterpy one can easily interpolate a given function. For instance, take the function f(x) = x\sin(10x) in one dimension:

    import numpy as np

    def test_function(x):
        return x * np.sin(10*x)

In order to minterpy the function test_function one can use the top-level function interpolate:

    import minterpy as mp

    interpolant = mp.interpolate(test_function,spatial_dimension=1, poly_degree=64)

Here, interpolant is a callable function, which can be used as a representation of test_function. interpolate takes as arguments the function to interpolate, the number of dimensions (spatial_dimension), and the degree of the underlying polynomial (poly_degree).

You may adjust this parameter in order to get higher accuracy. For the example above, a degree of 64 produces an interpolant that reproduces the test_function almost up to machine precision:

    import matplotlib.pylab as plt

    x = np.linspace(-1,1,100)

    plt.plot(x,interpolant(x),label="interpolant")
    plt.plot(x,test_function(x),"k.",label="test function")
    plt.legend()
    plt.show()
Compare test function with its interpolant

For more comprehensive examples, see the getting started guides section of the minterpy docs.

Testing

After installation, we encourage you to at least run the unit tests of minterpy, where we use pytest to run the tests.

If you want to run all tests, type:

pytest [-vvv]

from within the minterpy source directory.

Contributing to minterpy

Contributions to the minterpy packages are highly welcome. We recommend you have a look at the CONTRIBUTING.md first. For a more comprehensive contribution guide visit the Contributors section of the documentation.

Credits and contributors

This work was partly funded by the Center for Advanced Systems Understanding (CASUS) that is financed by Germany’s Federal Ministry of Education and Research (BMBF) and by the Saxony Ministry for Science, Culture and Tourism (SMWK) with tax funds on the basis of the budget approved by the Saxony State Parliament.

The minterpy development team

The core development of the minterpy is currently done by a small team at the Center for Advanced Systems Understanding (CASUS), namely

Mathematical foundation

Former Members and Contributions

  • Jannik Michelfeit
  • Nico Hoffman (HZDR)
  • Steve Schmerler (HZDR)
  • Vidya Chandrashekar (TU Dresden)

Acknowledgement

Community

This package would not be possible without many contributions done from the community as well. For that, we want to send big thanks to:

  • the guy who will show me how to include a list of contributors on github/gitlab

License

MIT © minterpy development team

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minterpy-0.2.0a0.tar.gz (230.8 kB view details)

Uploaded Source

Built Distribution

minterpy-0.2.0a0-py3-none-any.whl (239.2 kB view details)

Uploaded Python 3

File details

Details for the file minterpy-0.2.0a0.tar.gz.

File metadata

  • Download URL: minterpy-0.2.0a0.tar.gz
  • Upload date:
  • Size: 230.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for minterpy-0.2.0a0.tar.gz
Algorithm Hash digest
SHA256 43f88fc5232af1a60bb315059ec502a3dd296c3544b802889fa2ed72d2f5da69
MD5 3aeca3a405351da829301ab646c78f34
BLAKE2b-256 6f4232f74121ae7f4c9b625b6779913a8a9d6c8c15147675292f1135c219c91d

See more details on using hashes here.

File details

Details for the file minterpy-0.2.0a0-py3-none-any.whl.

File metadata

  • Download URL: minterpy-0.2.0a0-py3-none-any.whl
  • Upload date:
  • Size: 239.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for minterpy-0.2.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 f219abb46f212cf5b5a784d40bffb7e2fef839bffa6385d7e9ad60184944a6fb
MD5 6d8d283cfb7d4354a9600e26ca8019d8
BLAKE2b-256 cc67e1455cb02f1fe823c2c330c163caab760f1ba0272b59bb249399652c033a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page