monte-carlo-simulation-engine
AI-Optimized Monte Carlo Simulation Engine
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.4%) to scientific vocabulary
Repository
AI-Optimized Monte Carlo Simulation Engine
Basic Info
Statistics
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
AI-Optimized Monte Carlo Simulation Engine
A high-performance Monte Carlo simulation engine with adaptive sampling strategies and optimization techniques. The engine supports multiple sampling methods, adaptive optimization, and provides comprehensive visualization tools for monitoring simulation progress.
Features
- Multiple sampling strategies:
SmartSampler: Adaptive importance sampling with best-sample trackingStratifiedSampler: Variance reduction through stratified samplingQuasiRandomSampler: Low-discrepancy sequences using Sobol points
- Adaptive optimization with gradient-based updates
- Real-time visualization tools for:
- Sampling distributions
- Convergence monitoring
- Distribution evolution
- Optimization progress
- Comprehensive test suite with high coverage
Installation
Clone the repository:
bash git clone https://github.com/yourusername/mc-sim-engine.git cd mc-sim-engineCreate and activate a virtual environment: ```bash
Windows
python -m venv venv .\venv\Scripts\activate
Unix/MacOS
python -m venv venv source venv/bin/activate ```
Install dependencies:
bash pip install -r requirements.txtInstall the package in development mode:
bash pip install -e .
Usage Example
```python import torch from src.core import MonteCarloSimulation from src.samplers import SmartSampler from src.core.optimizers import AdaptiveOptimizer
Define target function (e.g., estimating π)
def target_function(samples): return (samples ** 2).sum(dim=1) <= 1.0
Initialize components
sampler = SmartSampler(dimension=2) optimizer = AdaptiveOptimizer(learning_rate=0.001)
Create simulation
simulation = MonteCarloSimulation( sampler=sampler, targetfunction=targetfunction, optimizer=optimizer, nsamples=10000, batchsize=100, convergence_threshold=1e-6 )
Run simulation
results = simulation.run()
Access results
print(f"Estimated π: {4 * results['mean']:.6f}") print(f"Number of samples: {results['n_samples']}") print(f"Standard deviation: {results['std']:.6f}") ```
Running Tests
Run the full test suite (Windows):
bash
.\run_tests.bat
Or run specific components: ```bash
Run all tests with coverage
pytest tests/test_simulation.py -v "--cov=src" "--cov-report=term-missing"
Run specific test file
pytest tests/test_simulation.py -v ```
Code Quality
Format code:
bash
black src tests
Run linting:
bash
flake8 src tests
Project Structure
mc-sim-engine/
├── src/
│ ├── core/
│ │ ├── base.py # Abstract base classes
│ │ ├── simulation.py # Main simulation engine
│ │ └── optimizers.py # Optimization strategies
│ └── samplers/
│ ├── smart_sampler.py # Adaptive importance sampling
│ ├── stratified_sampler.py # Stratified sampling
│ └── quasi_random_sampler.py # Sobol sequence sampling
├── tests/
│ └── test_simulation.py # Test suite
├── requirements.txt # Project dependencies
├── *.bat # Batch files
└── README.md
License
This project is licensed under the Mozilla License - see the LICENSE file for details.
Development Workflow
Preparing Code for Push
Before pushing your changes, run the prepare script to ensure all checks pass:
bash
.\prepare_code.bat
This script will: 1. Format code with Black 2. Run flake8 linting 3. Run tests with coverage
Only push your code if all checks pass successfully.
Manual Quality Checks
If you need to run checks individually:
Format code:
bash
black src tests
Run linting:
bash
flake8 src tests --max-line-length=100 --extend-ignore=E203
Owner
- Name: Fuad Hasan
- Login: itsfuad
- Kind: user
- Website: https://itsfuad.me
- Repositories: 3
- Profile: https://github.com/itsfuad
A programmer of thousands of dreams encoded with love
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "Monte-Carlo-Simulation-Engine"
version: 1.0.0
date-released: 2025-03-24
url: https://github.com/itsfuad/Monte-Carlo-Simulation-Engine
type: software
authors:
- family-names: Hasan
given-names: Md. Fuad
orcid: "https://orcid.org/0009-0000-4610-5754"
GitHub Events
Total
- Watch event: 6
- Push event: 11
- Create event: 1
Last Year
- Watch event: 6
- Push event: 11
- Create event: 1
Issues and Pull Requests
Last synced: about 1 year ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v3 composite
- actions/setup-python v4 composite
- black >=23.3.0
- coverage >=7.2.7
- flake8 >=6.0.0
- matplotlib >=3.7.0
- matplotlib-stubs >=0.1.0
- numpy ==1.24.3
- pytest >=7.3.1
- pytest-cov >=4.1.0
- scipy >=1.10.0
- seaborn >=0.12.0
- sobol-seq >=0.2.0
- torch >=2.0.0
- tqdm >=4.65.0
- types-PyYAML >=6.0.12
- types-setuptools >=67.8.0
- types-tqdm >=4.65.0
- matplotlib *
- numpy *
- scipy *
- seaborn *
- torch *
- tqdm *