Montpy: Montecarlo and Quasi-Montecarlo Integration Library
This Python library provides implementations of Monte Carlo and Quasi-Monte Carlo methods for evaluating integrals. Monte Carlo methods are stochastic techniques based on random sampling, while Quasi-Monte Carlo methods use low-discrepancy sequences for sampling. These methods are particularly useful for high-dimensional integrals where other numerical methods may struggle.
Installation
You can install the library via pip:
pip install montpy
Usage
from montpy.mc import MonteCarloSolver, ImportanceSampler
from montpy.qmc import QuasiMonteCarloSolver
# Define the function to integrate
def f(samples):
x, y = samples.T
return x**2 + y**2
# Define the domain (multivariate case)
domain = [(0, 1), (0, 1)]
# Create the Monte Carlo solver (uniform distribution)
solver_mc = ImportanceSampler(f, domain)
integral_mc = solver_mc.integrate(num_samples=1000)
print("Estimated integral with Monte Carlo:", integral_mc)
# Define the function to integrate
def g(x, y):
return x*y
# Create the Quasi-Monte Carlo solver
solver_qmc = QuasiMonteCarloSolver(g, domain)
# Perform integration using Sobol sequence
integral_sobol = solver_qmc.integrate_sobol(num_samples=1000)
print("Estimated integral with Sobol sequence:", integral_sobol)
Contributing
Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request on GitHub.
License
This library is licensed under the MIT License. See the LICENSE file for details.
Release files for montpy 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| montpy-0.1.2.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| montpy-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.9 kB
Release files / montpy-0.1.2.tar.gz
| Download URL | montpy-0.1.2.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d13a9d67555938aa569805752464b079c7fc3e905ef4dd8df3e0bc5254d115d
|
|
BLAKE2b-256 checksum How to use checksums |
5a60184662adee458ec295d82a27fa9480083bb9c43c216e71896997a22d9c09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.12 Linux/5.15.0-92-generic
|
Release files / montpy-0.1.2-py3-none-any.whl
| Download URL | montpy-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
856d0b37073ba529c47ce6b00c463bf61cb92ac6656f95d94f9b7c2c6742dfc2
|
|
BLAKE2b-256 checksum How to use checksums |
e3ddc2bfe9f126dacfd10aa3c93bf1c4cdbdf0891cc5635070175fe354665bae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.10.12 Linux/5.15.0-92-generic
|