A Python toolkit for simulating intermittent processes and Levy flights.
Project description
Intermittent Lévy Processes (InterLevPy) Package
Overview
The InterLevPy package provides tools for simulating and analyzing intermittent and Lévy processes. It includes functions for:
- Process Simulation: Generate synthetic intermittent and Lévy flight trajectories.
- Moments calculation: Calculate theoretical and empirical moments of trajectories.
- Optimization: Fit model parameters to empirical data using optimization techniques.
- Classification: Distinguish between intermittent and Lévy processes using statistical methods.
- Utilities: Common functions for data analysis and processing.
This package is intended for researchers and practitioners working in statistical physics, complex systems, or any field where modeling and analysis of anomalous diffusion processes are relevant.
Installation
Clone the repository and install the package using pip:
git https://github.com/shailendrabhandari/IntLevPy.git
cd IntLevPy
pip install -e .
Note: The -e flag installs the package in editable mode, allowing for modifications without reinstallation.
Dependencies
Install all required dependencies using:
pip install -r requirements.txt
Usage
Example 1: Simulating and Analyzing an Intermittent Process
An example script is provided in the examples/ directory as run_intermittent_simulation.py. This script demonstrates how to simulate an intermittent process and perform parameter estimation.
Running the Example Script
python examples/run_intermittent_simulation.py
Script Overview
The script performs the following steps:
- Simulates an intermittent process using
intermittent3with random parameters within specified ranges. - Calculates the empirical second and fourth moments of the displacements.
- Performs Classification to separate different movement phases using statistical methods.
- Performs Optimization to estimate the model parameters by fitting theoretical moments to empirical data.
- Stores the optimized parameters and R-squared values for analysis.
- Plots the empirical and fitted moments for visualization.
Example 2: Simulating and Analyzing Multiple Lévy Flights
An example script is provided in the examples/ directory as run_levy_simulation.py. This script demonstrates how to simulate multiple Lévy flights over multiple iterations and perform parameter estimation.
Running the Example Script
python examples/run_levy_simulation.py
Script Overview
The script performs the following steps:
- Simulates multiple Lévy flights with random parameters within specified ranges.
- Calculates the empirical second and fourth moments of the displacements.
- Performs Optimization to estimate the Lévy exponent
alphaand mean velocityv_meanby fitting theoretical moments to empirical data. - Stores the optimized parameters and R-squared values for analysis.
- Plots the empirical and fitted moments for the first few iterations.
Package Structure
The package is organized into the following modules and subpackages:
IntLevPy/
├── __init__.py
├── processes.py # Simulation of intermittent and Lévy processes
├── moments.py # Calculation of statistical moments
├── optimization.py # Optimization routines for parameter estimation
├── classification.py # Classification methods for process analysis
├── utils.py # Utility functions for data processing
├── examples/
│ ├── run_simulation.py # Example script for intermittent processes
│ └── run_levy_simulation.py # Example script for Lévy processes
├── tests/ # Unit tests for the package
│ ├── __init__.py
│ ├── test_processes.py
│ ├── test_moments.py
│ ├── test_optimization.py
│ ├── test_classification.py
│ └── test_utils.py
├── setup.py # Installation script
└── README.md # Package documentation
Module Descriptions
-
intermittent_levy.processes
intermittent3: Simulate intermittent processes with specified parameters.levy_flight_2D_Simplified: Simulate 2D Lévy flights.
-
intermittent_levy.moments
mom2_serg_log: Calculate the logarithm of the second moment for intermittent processes.mom4_serg_log: Calculate the logarithm of the fourth moment for intermittent processes.levy_moments_log: Calculate the logarithm of the moments for Lévy flights.
-
intermittent_levy.optimization
to_optimize_mom4_and_2_serg_log: Objective function for optimizing intermittent process parameters based on moments.to_optimize_levy: Objective function for optimizing Lévy flight parameters.
-
intermittent_levy.classification
form_groups: Classify data into groups based on thresholds.real_k_and_fisher: Statistical analysis using Fisher's exact test.
-
intermittent_levy.utils
adjusted_r_square: Calculate the adjusted R-squared value.r_square: Calculate the R-squared value.adjusted_r_square_array: Calculate adjusted R-squared for multiple fits.
-
intermittent_levy.examples
run_simulation.py: Example script demonstrating how to simulate and analyze intermittent processes.run_levy_simulation.py: Example script demonstrating how to simulate and analyze Lévy processes.
-
intermittent_levy.tests
- Unit tests for each module to ensure code reliability and correctness.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the Repository: Create your own fork of the project.
- Create a Branch: Create a new branch for your feature or bug fix.
- Commit Changes: Make your changes and commit them with descriptive messages.
- Push to Branch: Push your changes to your forked repository.
- Submit a Pull Request: Submit a pull request to the
mainbranch of the original repository.
Please ensure your code adheres to the project's coding standards and passes all existing tests. Adding new tests for your contributions is highly appreciated.
License
This project is licensed under the MIT License.
Contact
- Shailendra Bhandari
- Pedro Lencastre
- Email: pedroreg@oslomet.no
For any questions or inquiries, please feel free to reach out via email.
No AUTHORS information provided.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file intlevpy-0.0.1.tar.gz.
File metadata
- Download URL: intlevpy-0.0.1.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee8083fca78e47238231d20e8aca01131e0eb7a1b8bc0725ae095c1bd892aca8
|
|
| MD5 |
ff1ff231e44536e4dc375f7d3d50f184
|
|
| BLAKE2b-256 |
7504c98005b875368065c3d564938504ba3f742d97b1671f59fc9c16f78a7370
|
File details
Details for the file IntLevPy-0.0.1-py3-none-any.whl.
File metadata
- Download URL: IntLevPy-0.0.1-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6afccc0bd6b03f036ae9e7b87f9446a70cf0752e7629398019ee589fe58fbd34
|
|
| MD5 |
5fff197c36dba5bc9f95361cc7fb8550
|
|
| BLAKE2b-256 |
e568422b896919ffe4c0e3eae32737b5326afee691873ea1cc42e2dc68eeb853
|