Skip to main content

Tools for moments, Gaussian quadrature,

Project description

QuadMomPy is a library for all sorts of fun with moments, Gaussian quadratures, orthogonal polynomials and quadrature-based moment methods for the solution of spatially homogeneous population balance equations.

Installation

The QuadMomPy package can be easily installed by

pip install quadmompy

or from the project repository

pip install -e .

A comprehensive documentation and additional examples are only available in the project repository on GitLab/GitHub. Use

git clone https://gitlab.com/puetzm/quadmompy.git

to clone the code from the GitLab repository or

git clone https://github.com/puetzmi/quadmompy.git

to clone from the project mirror on GitHub.

The repository also includes a Dockerfile to run tests and use the QuadMomPy package in a docker image.

Usage

A simple example of a moment inversion using the quadrature method of moments with the Wheeler algorithm to compute a Gaussian quadrature rule from a set of moments is given below.

import numpy as np
from quadmompy import qbmm
from quadmompy.qbmm.univariate import Qmom
from quadmompy.core.inversion import Wheeler

# Create Qmom object using the Wheeler
# algorithm for moment inversion
qmom = qbmm.new(qbmm_type=Qmom, qbmm_setup={'inv_type': Wheeler})

# Nodes `x` and weights `w` of a weighted
# sum of degenerate distributions
x = np.array([-0.5, 0.1, 1., 1.4])
w = np.array([0.15, 0.4, 0.4, 0.05])

# Compute moments of the distribution
n = len(x)
moments = np.vander(x, 2*n).T[::-1]@w

# Invert moments to obtain quadrature nodes and
# weights, which should, in this particular
# equal the nodes and weights defined above.
x_quad, w_quad = qmom.moment_inversion(moments)
print(f"x = {x_quad}")
print(f"w = {w_quad}")

For more examples of how to use the numerous classes provided with this package, see the tests directory and the examples directory in the project repository on GitLab (https://gitlab.com/puetzm/quadmompy.git) and the project mirror on GitHub(https://github.com/puetzmi/quadmompy.git).

License

Copyright (c) 2022 Michele Puetz.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

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

quadmompy-0.9.7.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

quadmompy-0.9.7-py3-none-any.whl (70.9 kB view details)

Uploaded Python 3

File details

Details for the file quadmompy-0.9.7.tar.gz.

File metadata

  • Download URL: quadmompy-0.9.7.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for quadmompy-0.9.7.tar.gz
Algorithm Hash digest
SHA256 bc20fc7dc0dbb94d41a2f4caec093d792316649a938b221b7bb3c79a2a1e1c49
MD5 b9b766edb44a7079d6936d0c9d8926e9
BLAKE2b-256 f42762ad8de722b042d87f4f82cb4f3f81eddcd75b681f91e95fb96dcb479c63

See more details on using hashes here.

File details

Details for the file quadmompy-0.9.7-py3-none-any.whl.

File metadata

  • Download URL: quadmompy-0.9.7-py3-none-any.whl
  • Upload date:
  • Size: 70.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for quadmompy-0.9.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7298c536eef0953aa9c30f62523028045a1549207c25e40802e75bc9f0e25b5b
MD5 3923f6e5816268b724227fa9bfb001b6
BLAKE2b-256 e752fc2e37aaa8d98f5846c63ca791fc758ae5738c25941d0509aa3c19c48e29

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