MC-post 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mc_post-0.1.1/CHANGELOG.md +74 -0
- mc_post-0.1.1/LICENSE +21 -0
- mc_post-0.1.1/MANIFEST.in +47 -0
- mc_post-0.1.1/MC_post.egg-info/SOURCES.txt +63 -0
- mc_post-0.1.1/PKG-INFO +391 -0
- mc_post-0.1.1/README.md +326 -0
- mc_post-0.1.1/benchmarks/__init__.py +1 -0
- mc_post-0.1.1/benchmarks/benchmark_gsa.py +516 -0
- mc_post-0.1.1/benchmarks/benchmark_integration.py +588 -0
- mc_post-0.1.1/benchmarks/run_benchmarks.py +140 -0
- mc_post-0.1.1/docs/BACKWARD_COMPATIBILITY.md +405 -0
- mc_post-0.1.1/docs/MIGRATION_GUIDE.md +442 -0
- mc_post-0.1.1/docs/RELEASE_GUIDE.md +284 -0
- mc_post-0.1.1/docs/examples/financial_risk_analysis.py +291 -0
- mc_post-0.1.1/docs/extension_guide.md +618 -0
- mc_post-0.1.1/docs/tutorials/getting_started.ipynb +471 -0
- mc_post-0.1.1/docs/tutorials/gsa_comprehensive.ipynb +533 -0
- mc_post-0.1.1/docs/tutorials/gsa_comprehensive.md +232 -0
- mc_post-0.1.1/examples/climate_sensitivity.py +231 -0
- mc_post-0.1.1/examples/financial_risk.py +180 -0
- mc_post-0.1.1/examples/gsa_basic_example.py +124 -0
- mc_post-0.1.1/examples/integration_comparison.py +234 -0
- mc_post-0.1.1/mcpost/__init__.py +92 -0
- mc_post-0.1.1/mcpost/_version.py +14 -0
- mc_post-0.1.1/mcpost/gsa/__init__.py +51 -0
- mc_post-0.1.1/mcpost/gsa/base.py +481 -0
- mc_post-0.1.1/mcpost/gsa/chunked_pipeline.py +410 -0
- mc_post-0.1.1/mcpost/gsa/kernels.py +143 -0
- mc_post-0.1.1/mcpost/gsa/metrics.py +309 -0
- mc_post-0.1.1/mcpost/gsa/pipeline.py +371 -0
- mc_post-0.1.1/mcpost/gsa/plotting.py +276 -0
- mc_post-0.1.1/mcpost/integration/__init__.py +48 -0
- mc_post-0.1.1/mcpost/integration/base.py +638 -0
- mc_post-0.1.1/mcpost/integration/chunked_integration.py +306 -0
- mc_post-0.1.1/mcpost/integration/importance.py +142 -0
- mc_post-0.1.1/mcpost/integration/monte_carlo.py +113 -0
- mc_post-0.1.1/mcpost/integration/quasi_monte_carlo.py +256 -0
- mc_post-0.1.1/mcpost/py.typed +1 -0
- mc_post-0.1.1/mcpost/utils/__init__.py +50 -0
- mc_post-0.1.1/mcpost/utils/chunked.py +441 -0
- mc_post-0.1.1/mcpost/utils/config.py +216 -0
- mc_post-0.1.1/mcpost/utils/data.py +86 -0
- mc_post-0.1.1/mcpost/utils/profiling.py +563 -0
- mc_post-0.1.1/mcpost/utils/validation.py +202 -0
- mc_post-0.1.1/pyproject.toml +163 -0
- mc_post-0.1.1/setup.cfg +4 -0
- mc_post-0.1.1/tests/__init__.py +1 -0
- mc_post-0.1.1/tests/conftest.py +157 -0
- mc_post-0.1.1/tests/integration/__init__.py +1 -0
- mc_post-0.1.1/tests/integration/test_end_to_end.py +482 -0
- mc_post-0.1.1/tests/integration/test_examples.py +287 -0
- mc_post-0.1.1/tests/legacy_mocks/gsa_pipeline.py +119 -0
- mc_post-0.1.1/tests/legacy_mocks/mc_int.py +75 -0
- mc_post-0.1.1/tests/test_config_properties.py +228 -0
- mc_post-0.1.1/tests/test_gsa/__init__.py +1 -0
- mc_post-0.1.1/tests/test_gsa/test_pipeline.py +265 -0
- mc_post-0.1.1/tests/test_gsa/test_properties.py +436 -0
- mc_post-0.1.1/tests/test_gsa_backward_compatibility.py +315 -0
- mc_post-0.1.1/tests/test_integration/__init__.py +1 -0
- mc_post-0.1.1/tests/test_integration/test_monte_carlo.py +205 -0
- mc_post-0.1.1/tests/test_integration/test_properties.py +318 -0
- mc_post-0.1.1/tests/test_integration_backward_compatibility.py +436 -0
- mc_post-0.1.1/tests/test_package_structure.py +253 -0
- mc_post-0.1.1/tests/test_utils/__init__.py +1 -0
- mc_post-0.1.1/tests/test_utils/test_config.py +337 -0
- mc_post-0.1.1/tests/test_utils/test_validation.py +279 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.1] - 2026-01-05
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Professional GitHub Pages documentation site with Jekyll
|
|
14
|
+
- Comprehensive tutorials: Getting Started and Advanced GSA
|
|
15
|
+
- Financial risk analysis example
|
|
16
|
+
- Automated documentation deployment workflow
|
|
17
|
+
- Repository cleanup with proper .gitignore configuration
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- GitHub Actions CI/CD pipeline (updated deprecated actions)
|
|
21
|
+
- Jekyll build errors in documentation deployment
|
|
22
|
+
- Jupyter notebook JSON parsing issues
|
|
23
|
+
- Broken documentation links and repository URLs
|
|
24
|
+
- Code complexity issues in CI pipeline
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- Streamlined CI workflow for faster builds
|
|
28
|
+
- Enhanced documentation structure and navigation
|
|
29
|
+
- Improved notebook-to-HTML conversion with better templates
|
|
30
|
+
- Repository organization (removed development clutter)
|
|
31
|
+
|
|
32
|
+
### Infrastructure
|
|
33
|
+
- Ultra-fast CI focusing on core functionality
|
|
34
|
+
- Robust error handling in documentation builds
|
|
35
|
+
- Professional documentation site deployment
|
|
36
|
+
- Clean repository structure for better user experience
|
|
37
|
+
|
|
38
|
+
## [0.1.0] - 2024-01-05
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
- Initial release of MCPost package
|
|
42
|
+
- Core GSA functionality with multiple sensitivity metrics
|
|
43
|
+
- Monte Carlo and Quasi-Monte Carlo integration methods
|
|
44
|
+
- Modern Python packaging with pyproject.toml
|
|
45
|
+
- Comprehensive test suite with property-based tests
|
|
46
|
+
- Documentation and examples
|
|
47
|
+
- CI/CD workflows for automated testing and release
|
|
48
|
+
- Distribution and release infrastructure
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
- **Global Sensitivity Analysis**:
|
|
52
|
+
- Mutual Information and Distance Correlation metrics
|
|
53
|
+
- Permutation Importance with Random Forest
|
|
54
|
+
- Gaussian Process surrogates with ARD kernels
|
|
55
|
+
- Sobol' indices for variance-based analysis
|
|
56
|
+
- Partial Dependence Plots for interpretability
|
|
57
|
+
- Chunked processing for large datasets
|
|
58
|
+
|
|
59
|
+
- **Monte Carlo Integration**:
|
|
60
|
+
- Standard Monte Carlo with importance sampling
|
|
61
|
+
- Quasi-Monte Carlo methods (Sobol, Halton)
|
|
62
|
+
- Automatic integration with adaptive strategies
|
|
63
|
+
- Flexible PDF specification
|
|
64
|
+
- Chunked integration for memory efficiency
|
|
65
|
+
|
|
66
|
+
- **Package Infrastructure**:
|
|
67
|
+
- Modern packaging with optional dependencies
|
|
68
|
+
- Type hints and comprehensive documentation
|
|
69
|
+
- Extensive testing with property-based tests
|
|
70
|
+
- Performance optimizations for large datasets
|
|
71
|
+
- Backward compatibility with existing code
|
|
72
|
+
- Extension interfaces for custom methods
|
|
73
|
+
- Automated CI/CD with GitHub Actions
|
|
74
|
+
- PyPI distribution ready
|
mc_post-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 MCPost Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Include package metadata and documentation
|
|
2
|
+
include README.md
|
|
3
|
+
include LICENSE
|
|
4
|
+
include CHANGELOG.md
|
|
5
|
+
include pyproject.toml
|
|
6
|
+
|
|
7
|
+
# Include type information
|
|
8
|
+
include mcpost/py.typed
|
|
9
|
+
|
|
10
|
+
# Include test data and configuration files
|
|
11
|
+
recursive-include tests *.py
|
|
12
|
+
recursive-include tests *.json
|
|
13
|
+
recursive-include tests *.csv
|
|
14
|
+
recursive-include tests *.txt
|
|
15
|
+
|
|
16
|
+
# Include documentation
|
|
17
|
+
recursive-include docs *.md
|
|
18
|
+
recursive-include docs *.rst
|
|
19
|
+
recursive-include docs *.py
|
|
20
|
+
recursive-include docs *.ipynb
|
|
21
|
+
recursive-include docs *.png
|
|
22
|
+
recursive-include docs *.jpg
|
|
23
|
+
recursive-include docs *.svg
|
|
24
|
+
|
|
25
|
+
# Include examples
|
|
26
|
+
recursive-include examples *.py
|
|
27
|
+
recursive-include examples *.ipynb
|
|
28
|
+
recursive-include examples *.md
|
|
29
|
+
recursive-include examples *.csv
|
|
30
|
+
recursive-include examples *.json
|
|
31
|
+
|
|
32
|
+
# Include benchmarks
|
|
33
|
+
recursive-include benchmarks *.py
|
|
34
|
+
|
|
35
|
+
# Exclude development and build artifacts
|
|
36
|
+
global-exclude *.pyc
|
|
37
|
+
global-exclude *.pyo
|
|
38
|
+
global-exclude *.pyd
|
|
39
|
+
global-exclude __pycache__
|
|
40
|
+
global-exclude .git*
|
|
41
|
+
global-exclude .DS_Store
|
|
42
|
+
global-exclude *.so
|
|
43
|
+
global-exclude .coverage
|
|
44
|
+
global-exclude .pytest_cache
|
|
45
|
+
prune build
|
|
46
|
+
prune dist
|
|
47
|
+
prune *.egg-info
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
CHANGELOG.md
|
|
2
|
+
LICENSE
|
|
3
|
+
MANIFEST.in
|
|
4
|
+
README.md
|
|
5
|
+
pyproject.toml
|
|
6
|
+
benchmarks/__init__.py
|
|
7
|
+
benchmarks/benchmark_gsa.py
|
|
8
|
+
benchmarks/benchmark_integration.py
|
|
9
|
+
benchmarks/run_benchmarks.py
|
|
10
|
+
docs/BACKWARD_COMPATIBILITY.md
|
|
11
|
+
docs/MIGRATION_GUIDE.md
|
|
12
|
+
docs/RELEASE_GUIDE.md
|
|
13
|
+
docs/extension_guide.md
|
|
14
|
+
docs/examples/financial_risk_analysis.py
|
|
15
|
+
docs/tutorials/getting_started.ipynb
|
|
16
|
+
docs/tutorials/gsa_comprehensive.ipynb
|
|
17
|
+
docs/tutorials/gsa_comprehensive.md
|
|
18
|
+
examples/climate_sensitivity.py
|
|
19
|
+
examples/financial_risk.py
|
|
20
|
+
examples/gsa_basic_example.py
|
|
21
|
+
examples/integration_comparison.py
|
|
22
|
+
mcpost/__init__.py
|
|
23
|
+
mcpost/_version.py
|
|
24
|
+
mcpost/py.typed
|
|
25
|
+
mcpost/gsa/__init__.py
|
|
26
|
+
mcpost/gsa/base.py
|
|
27
|
+
mcpost/gsa/chunked_pipeline.py
|
|
28
|
+
mcpost/gsa/kernels.py
|
|
29
|
+
mcpost/gsa/metrics.py
|
|
30
|
+
mcpost/gsa/pipeline.py
|
|
31
|
+
mcpost/gsa/plotting.py
|
|
32
|
+
mcpost/integration/__init__.py
|
|
33
|
+
mcpost/integration/base.py
|
|
34
|
+
mcpost/integration/chunked_integration.py
|
|
35
|
+
mcpost/integration/importance.py
|
|
36
|
+
mcpost/integration/monte_carlo.py
|
|
37
|
+
mcpost/integration/quasi_monte_carlo.py
|
|
38
|
+
mcpost/utils/__init__.py
|
|
39
|
+
mcpost/utils/chunked.py
|
|
40
|
+
mcpost/utils/config.py
|
|
41
|
+
mcpost/utils/data.py
|
|
42
|
+
mcpost/utils/profiling.py
|
|
43
|
+
mcpost/utils/validation.py
|
|
44
|
+
tests/__init__.py
|
|
45
|
+
tests/conftest.py
|
|
46
|
+
tests/test_config_properties.py
|
|
47
|
+
tests/test_gsa_backward_compatibility.py
|
|
48
|
+
tests/test_integration_backward_compatibility.py
|
|
49
|
+
tests/test_package_structure.py
|
|
50
|
+
tests/integration/__init__.py
|
|
51
|
+
tests/integration/test_end_to_end.py
|
|
52
|
+
tests/integration/test_examples.py
|
|
53
|
+
tests/legacy_mocks/gsa_pipeline.py
|
|
54
|
+
tests/legacy_mocks/mc_int.py
|
|
55
|
+
tests/test_gsa/__init__.py
|
|
56
|
+
tests/test_gsa/test_pipeline.py
|
|
57
|
+
tests/test_gsa/test_properties.py
|
|
58
|
+
tests/test_integration/__init__.py
|
|
59
|
+
tests/test_integration/test_monte_carlo.py
|
|
60
|
+
tests/test_integration/test_properties.py
|
|
61
|
+
tests/test_utils/__init__.py
|
|
62
|
+
tests/test_utils/test_config.py
|
|
63
|
+
tests/test_utils/test_validation.py
|
mc_post-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: MC-post
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Monte Carlo Post-analysis package for global sensitivity analysis and integration
|
|
5
|
+
Author-email: MCPost Contributors <mcpost@example.com>
|
|
6
|
+
Maintainer-email: MCPost Contributors <mcpost@example.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/zzhang0123/mcpost
|
|
9
|
+
Project-URL: Repository, https://github.com/zzhang0123/mcpost
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/zzhang0123/mcpost/issues
|
|
11
|
+
Keywords: monte-carlo,sensitivity-analysis,integration,statistics
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: numpy>=1.20.0
|
|
26
|
+
Requires-Dist: pandas>=1.3.0
|
|
27
|
+
Requires-Dist: scikit-learn>=1.0.0
|
|
28
|
+
Requires-Dist: scipy>=1.7.0
|
|
29
|
+
Requires-Dist: dcor>=0.5.0
|
|
30
|
+
Requires-Dist: SALib>=1.4.0
|
|
31
|
+
Requires-Dist: tqdm>=4.60.0
|
|
32
|
+
Requires-Dist: psutil>=5.8.0
|
|
33
|
+
Provides-Extra: viz
|
|
34
|
+
Requires-Dist: matplotlib>=3.5.0; extra == "viz"
|
|
35
|
+
Provides-Extra: jupyter
|
|
36
|
+
Requires-Dist: jupyter>=1.0.0; extra == "jupyter"
|
|
37
|
+
Requires-Dist: notebook>=6.4.0; extra == "jupyter"
|
|
38
|
+
Requires-Dist: ipykernel>=6.0.0; extra == "jupyter"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-cov>=3.0; extra == "dev"
|
|
42
|
+
Requires-Dist: hypothesis>=6.0; extra == "dev"
|
|
43
|
+
Requires-Dist: black>=22.0; extra == "dev"
|
|
44
|
+
Requires-Dist: flake8>=4.0; extra == "dev"
|
|
45
|
+
Requires-Dist: mypy>=0.900; extra == "dev"
|
|
46
|
+
Requires-Dist: build>=0.8.0; extra == "dev"
|
|
47
|
+
Requires-Dist: twine>=4.0.0; extra == "dev"
|
|
48
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
49
|
+
Requires-Dist: safety>=2.0.0; extra == "dev"
|
|
50
|
+
Requires-Dist: bandit>=1.7.0; extra == "dev"
|
|
51
|
+
Requires-Dist: radon>=5.1.0; extra == "dev"
|
|
52
|
+
Requires-Dist: xenon>=0.9.0; extra == "dev"
|
|
53
|
+
Requires-Dist: docstr-coverage>=2.0.0; extra == "dev"
|
|
54
|
+
Requires-Dist: pip-audit>=2.0.0; extra == "dev"
|
|
55
|
+
Provides-Extra: docs
|
|
56
|
+
Requires-Dist: sphinx>=4.0; extra == "docs"
|
|
57
|
+
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
|
|
58
|
+
Requires-Dist: jupyter>=1.0; extra == "docs"
|
|
59
|
+
Requires-Dist: nbsphinx>=0.8; extra == "docs"
|
|
60
|
+
Requires-Dist: nbconvert>=6.0; extra == "docs"
|
|
61
|
+
Requires-Dist: readme-renderer>=35.0; extra == "docs"
|
|
62
|
+
Provides-Extra: all
|
|
63
|
+
Requires-Dist: mcpost[dev,docs,jupyter,viz]; extra == "all"
|
|
64
|
+
Dynamic: license-file
|
|
65
|
+
|
|
66
|
+
# MCPost: Monte Carlo Post-analysis Package
|
|
67
|
+
|
|
68
|
+
[](https://badge.fury.io/py/mcpost)
|
|
69
|
+
[](https://www.python.org/downloads/)
|
|
70
|
+
[](https://opensource.org/licenses/MIT)
|
|
71
|
+
|
|
72
|
+
MCPost is a comprehensive Python package for post-analysis of Monte Carlo samples, providing tools for global sensitivity analysis (GSA) and Monte Carlo integration with modern packaging standards and extensive documentation.
|
|
73
|
+
|
|
74
|
+
## Features
|
|
75
|
+
|
|
76
|
+
### Global Sensitivity Analysis
|
|
77
|
+
- **Multiple sensitivity metrics**: Mutual Information, Distance Correlation, Permutation Importance
|
|
78
|
+
- **Gaussian Process surrogates** with Automatic Relevance Determination (ARD)
|
|
79
|
+
- **Sobol' indices** for variance-based sensitivity analysis
|
|
80
|
+
- **Partial Dependence Plots** for interpretable results
|
|
81
|
+
- **Robust preprocessing** with automatic constant column detection
|
|
82
|
+
|
|
83
|
+
### Monte Carlo Integration
|
|
84
|
+
- **Standard Monte Carlo** integration with importance sampling
|
|
85
|
+
- **Quasi-Monte Carlo** methods (Sobol, Halton sequences)
|
|
86
|
+
- **Automatic integration** with adaptive sampling strategies
|
|
87
|
+
- **Flexible PDF specification** for target and sampling distributions
|
|
88
|
+
|
|
89
|
+
### Modern Package Features
|
|
90
|
+
- **Type hints** and comprehensive documentation
|
|
91
|
+
- **Modular design** with clean public APIs
|
|
92
|
+
- **Optional dependencies** for visualization and development
|
|
93
|
+
- **Extensive testing** with property-based tests
|
|
94
|
+
- **Performance optimizations** for large datasets
|
|
95
|
+
|
|
96
|
+
## Installation
|
|
97
|
+
|
|
98
|
+
MCPost supports multiple installation methods to suit different use cases:
|
|
99
|
+
|
|
100
|
+
### Basic Installation
|
|
101
|
+
|
|
102
|
+
For core functionality (GSA and integration without plotting):
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
pip install mcpost
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Installation with Visualization Support
|
|
109
|
+
|
|
110
|
+
For full functionality including plotting and visualization:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pip install mcpost[viz]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Development Installation
|
|
117
|
+
|
|
118
|
+
For contributors and developers:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Clone the repository
|
|
122
|
+
git clone https://github.com/mcpost/mcpost.git
|
|
123
|
+
cd mcpost
|
|
124
|
+
|
|
125
|
+
# Install in development mode with all dependencies
|
|
126
|
+
pip install -e .[dev]
|
|
127
|
+
|
|
128
|
+
# Run tests to verify installation
|
|
129
|
+
pytest
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Installation from Source
|
|
133
|
+
|
|
134
|
+
For the latest development version:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pip install git+https://github.com/zzhang0123/mcpost.git
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Conda Installation
|
|
141
|
+
|
|
142
|
+
MCPost will be available on conda-forge (coming soon):
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
conda install -c conda-forge mcpost
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Quick Start
|
|
149
|
+
|
|
150
|
+
### Global Sensitivity Analysis
|
|
151
|
+
|
|
152
|
+
MCPost provides comprehensive GSA capabilities with multiple sensitivity metrics:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
import numpy as np
|
|
156
|
+
from mcpost import gsa_pipeline
|
|
157
|
+
|
|
158
|
+
# Generate sample data (Ishigami function example)
|
|
159
|
+
np.random.seed(42)
|
|
160
|
+
n_samples = 1000
|
|
161
|
+
X = np.random.uniform(-np.pi, np.pi, (n_samples, 3))
|
|
162
|
+
|
|
163
|
+
# Ishigami function: f(x1,x2,x3) = sin(x1) + 7*sin(x2)^2 + 0.1*x3^4*sin(x1)
|
|
164
|
+
y = (np.sin(X[:, 0]) +
|
|
165
|
+
7 * np.sin(X[:, 1])**2 +
|
|
166
|
+
0.1 * X[:, 2]**4 * np.sin(X[:, 0]))
|
|
167
|
+
Y = y.reshape(-1, 1)
|
|
168
|
+
|
|
169
|
+
# Run comprehensive GSA analysis
|
|
170
|
+
results = gsa_pipeline(
|
|
171
|
+
X, Y,
|
|
172
|
+
param_names=["x1", "x2", "x3"],
|
|
173
|
+
feature_names=["ishigami"],
|
|
174
|
+
scaler="minmax",
|
|
175
|
+
enable_sobol=True,
|
|
176
|
+
enable_gp=True,
|
|
177
|
+
enable_perm=True,
|
|
178
|
+
make_pdp=True
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
# View sensitivity results
|
|
182
|
+
print("Sensitivity Analysis Results:")
|
|
183
|
+
print(results["results"]["ishigami"]["table"])
|
|
184
|
+
|
|
185
|
+
# Plot sensitivity metrics (requires matplotlib)
|
|
186
|
+
from mcpost import plot_sensitivity_metrics
|
|
187
|
+
plot_sensitivity_metrics(results, save_path="sensitivity_plot.png")
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Advanced GSA Usage
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
# Custom GSA configuration
|
|
194
|
+
from mcpost import GSAConfig, gsa_for_target
|
|
195
|
+
|
|
196
|
+
# Configure GSA parameters
|
|
197
|
+
config = GSAConfig()
|
|
198
|
+
config.DEFAULT_SCALER = "standard"
|
|
199
|
+
config.DEFAULT_N_SOBOL = 8192
|
|
200
|
+
|
|
201
|
+
# Run GSA for specific target
|
|
202
|
+
target_results = gsa_for_target(
|
|
203
|
+
X, Y[:, 0], # Single target
|
|
204
|
+
param_names=["x1", "x2", "x3"],
|
|
205
|
+
target_name="ishigami",
|
|
206
|
+
scaler=config.DEFAULT_SCALER,
|
|
207
|
+
n_sobol=config.DEFAULT_N_SOBOL
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Monte Carlo Integration
|
|
212
|
+
|
|
213
|
+
MCPost supports various integration methods for different use cases:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
import numpy as np
|
|
217
|
+
from mcpost import monte_carlo_integral, qmc_integral_auto
|
|
218
|
+
|
|
219
|
+
# Define integration problem: E[x*sin(y)] where (x,y) ~ N(0,I)
|
|
220
|
+
def target_pdf(theta):
|
|
221
|
+
"""Target probability density function (standard normal)"""
|
|
222
|
+
return np.exp(-0.5 * np.sum(theta**2, axis=1)) / (2 * np.pi)
|
|
223
|
+
|
|
224
|
+
def integrand(theta):
|
|
225
|
+
"""Function to integrate: f(x,y) = x * sin(y)"""
|
|
226
|
+
return theta[:, 0] * np.sin(theta[:, 1])
|
|
227
|
+
|
|
228
|
+
# Method 1: Standard Monte Carlo
|
|
229
|
+
np.random.seed(42)
|
|
230
|
+
theta_samples = np.random.normal(0, 1, (5000, 2))
|
|
231
|
+
f_values = integrand(theta_samples)
|
|
232
|
+
|
|
233
|
+
mc_result = monte_carlo_integral(theta_samples, f_values, target_pdf)
|
|
234
|
+
print(f"Monte Carlo result: {mc_result['integral']:.6f} ± {mc_result['uncertainty']:.6f}")
|
|
235
|
+
|
|
236
|
+
# Method 2: Quasi-Monte Carlo (automatic)
|
|
237
|
+
qmc_result = qmc_integral_auto(
|
|
238
|
+
N_samples=4096,
|
|
239
|
+
N_params=2,
|
|
240
|
+
data_func=integrand,
|
|
241
|
+
p_target=target_pdf,
|
|
242
|
+
bounds=[(-4, 4), (-4, 4)] # Integration bounds
|
|
243
|
+
)
|
|
244
|
+
print(f"QMC result: {qmc_result['integral']:.6f}")
|
|
245
|
+
|
|
246
|
+
# Method 3: QMC with importance sampling
|
|
247
|
+
from mcpost import qmc_integral_importance
|
|
248
|
+
|
|
249
|
+
def importance_pdf(theta):
|
|
250
|
+
"""Importance sampling distribution"""
|
|
251
|
+
return np.exp(-0.25 * np.sum(theta**2, axis=1)) / (4 * np.pi)
|
|
252
|
+
|
|
253
|
+
qmc_is_result = qmc_integral_importance(
|
|
254
|
+
N_samples=2048,
|
|
255
|
+
N_params=2,
|
|
256
|
+
data_func=integrand,
|
|
257
|
+
p_target=target_pdf,
|
|
258
|
+
q_sample=importance_pdf,
|
|
259
|
+
bounds=[(-3, 3), (-3, 3)]
|
|
260
|
+
)
|
|
261
|
+
print(f"QMC + Importance Sampling: {qmc_is_result['integral']:.6f}")
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Integration with Custom Distributions
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
# Example: Integration over custom parameter space
|
|
268
|
+
def custom_target(theta):
|
|
269
|
+
"""Custom target distribution (mixture of Gaussians)"""
|
|
270
|
+
comp1 = 0.6 * np.exp(-0.5 * np.sum((theta - 1)**2, axis=1))
|
|
271
|
+
comp2 = 0.4 * np.exp(-0.5 * np.sum((theta + 1)**2, axis=1))
|
|
272
|
+
return (comp1 + comp2) / (2 * np.pi)
|
|
273
|
+
|
|
274
|
+
def complex_integrand(theta):
|
|
275
|
+
"""More complex integrand"""
|
|
276
|
+
return np.exp(theta[:, 0]) * np.cos(theta[:, 1]) * theta[:, 0]**2
|
|
277
|
+
|
|
278
|
+
# Use adaptive QMC integration
|
|
279
|
+
result = qmc_integral_auto(
|
|
280
|
+
N_samples=8192,
|
|
281
|
+
N_params=2,
|
|
282
|
+
data_func=complex_integrand,
|
|
283
|
+
p_target=custom_target,
|
|
284
|
+
bounds=[(-3, 3), (-3, 3)],
|
|
285
|
+
qmc_method="sobol" # or "halton"
|
|
286
|
+
)
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Documentation and Resources
|
|
290
|
+
|
|
291
|
+
### Complete Documentation
|
|
292
|
+
- **[Getting Started Tutorial](docs/tutorials/getting_started.ipynb)**: Your first MCPost analysis
|
|
293
|
+
- **[GSA Deep Dive](docs/tutorials/gsa_comprehensive.md)**: Advanced sensitivity analysis
|
|
294
|
+
- **[Extension Guide](docs/extension_guide.md)**: Creating custom methods
|
|
295
|
+
- **[Migration Guide](docs/MIGRATION_GUIDE.md)**: Migrating from legacy scripts
|
|
296
|
+
|
|
297
|
+
### Quick References
|
|
298
|
+
- **[Backward Compatibility](docs/BACKWARD_COMPATIBILITY.md)**: Version compatibility policy
|
|
299
|
+
- **[Release Guide](docs/RELEASE_GUIDE.md)**: Release process and versioning
|
|
300
|
+
|
|
301
|
+
### Learning Resources
|
|
302
|
+
- **[Getting Started Tutorial](docs/tutorials/getting_started.ipynb)**: Your first MCPost analysis
|
|
303
|
+
- **[GSA Deep Dive](docs/tutorials/gsa_comprehensive.md)**: Advanced sensitivity analysis
|
|
304
|
+
|
|
305
|
+
### Example Applications
|
|
306
|
+
- **[Climate Modeling](examples/climate_sensitivity.py)**: GSA for climate model parameters
|
|
307
|
+
- **[Integration Comparison](examples/integration_comparison.py)**: Monte Carlo integration examples
|
|
308
|
+
|
|
309
|
+
## Requirements
|
|
310
|
+
|
|
311
|
+
### Core Dependencies
|
|
312
|
+
- Python 3.8+
|
|
313
|
+
- NumPy >= 1.20.0
|
|
314
|
+
- Pandas >= 1.3.0
|
|
315
|
+
- Scikit-learn >= 1.0.0
|
|
316
|
+
- SciPy >= 1.7.0
|
|
317
|
+
- dcor >= 0.5.0
|
|
318
|
+
- SALib >= 1.4.0
|
|
319
|
+
|
|
320
|
+
### Optional Dependencies
|
|
321
|
+
- **Visualization**: matplotlib >= 3.5.0
|
|
322
|
+
- **Development**: pytest, hypothesis, black, mypy
|
|
323
|
+
- **Documentation**: sphinx, jupyter, nbsphinx
|
|
324
|
+
|
|
325
|
+
## Contributing
|
|
326
|
+
|
|
327
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
328
|
+
|
|
329
|
+
### Development Setup
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
git clone https://github.com/zzhang0123/mcpost.git
|
|
333
|
+
cd mcpost
|
|
334
|
+
pip install -e .[dev]
|
|
335
|
+
pytest
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Testing
|
|
339
|
+
|
|
340
|
+
MCPost includes a comprehensive test suite:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
# Run all tests (excludes backward compatibility tests)
|
|
344
|
+
pytest tests/
|
|
345
|
+
|
|
346
|
+
# Run specific test categories
|
|
347
|
+
pytest tests/test_gsa/ # GSA functionality tests
|
|
348
|
+
pytest tests/test_integration/ # Integration tests
|
|
349
|
+
pytest tests/test_utils/ # Utility tests
|
|
350
|
+
|
|
351
|
+
# Run property-based tests
|
|
352
|
+
pytest tests/ -k "property"
|
|
353
|
+
|
|
354
|
+
# Run with coverage
|
|
355
|
+
pytest tests/ --cov=mcpost --cov-report=html
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
**Backward Compatibility Tests**: These require the legacy mock files `gsa_pipeline.py` and `mc_int.py` located in `tests/legacy_mocks/` and are skipped in CI. For local development:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
# Place original files in repository root, then:
|
|
362
|
+
pytest tests/test_gsa_backward_compatibility.py
|
|
363
|
+
pytest tests/test_integration_backward_compatibility.py
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## License
|
|
367
|
+
|
|
368
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
369
|
+
|
|
370
|
+
## Citation
|
|
371
|
+
|
|
372
|
+
If you use MCPost in your research, please cite:
|
|
373
|
+
|
|
374
|
+
```bibtex
|
|
375
|
+
@software{mcpost,
|
|
376
|
+
title={MCPost: Monte Carlo Post-analysis Package},
|
|
377
|
+
author={MCPost Contributors},
|
|
378
|
+
url={https://github.com/zzhang0123/mcpost},
|
|
379
|
+
version={0.1.0},
|
|
380
|
+
year={2024}
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## Acknowledgments
|
|
385
|
+
|
|
386
|
+
MCPost builds upon several excellent open-source libraries:
|
|
387
|
+
- [Scikit-learn](https://scikit-learn.org/) for machine learning algorithms
|
|
388
|
+
- [SALib](https://salib.readthedocs.io/) for Sobol' sensitivity analysis
|
|
389
|
+
- [dcor](https://dcor.readthedocs.io/) for distance correlation
|
|
390
|
+
- [SciPy](https://scipy.org/) for scientific computing
|
|
391
|
+
- [NumPy](https://numpy.org/) for numerical computing
|