Skip to main content

A Python toolkit for simulating intermittent processes and Levy flights.

Project description

Documentation Status license PyPI - Python Version PyPI Downloads GitHub watchers GitHub stars

Intermittent Lévy Processes (InterLevPy) Package

model

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:

  1. Simulates an intermittent process using intermittent3 with random parameters within specified ranges.
  2. Calculates the empirical second and fourth moments of the displacements.
  3. Performs Classification to separate different movement phases using statistical methods.
  4. Performs Optimization to estimate the model parameters by fitting theoretical moments to empirical data.
  5. Stores the optimized parameters and R-squared values for analysis.
  6. 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:

  1. Simulates multiple Lévy flights with random parameters within specified ranges.
  2. Calculates the empirical second and fourth moments of the displacements.
  3. Performs Optimization to estimate the Lévy exponent alpha and mean velocity v_mean by fitting theoretical moments to empirical data.
  4. Stores the optimized parameters and R-squared values for analysis.
  5. 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:

  1. Fork the Repository: Create your own fork of the project.
  2. Create a Branch: Create a new branch for your feature or bug fix.
  3. Commit Changes: Make your changes and commit them with descriptive messages.
  4. Push to Branch: Push your changes to your forked repository.
  5. Submit a Pull Request: Submit a pull request to the main branch 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

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

intlevpy-0.0.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

IntLevPy-0.0.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

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

Hashes for intlevpy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ee8083fca78e47238231d20e8aca01131e0eb7a1b8bc0725ae095c1bd892aca8
MD5 ff1ff231e44536e4dc375f7d3d50f184
BLAKE2b-256 7504c98005b875368065c3d564938504ba3f742d97b1671f59fc9c16f78a7370

See more details on using hashes here.

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

Hashes for IntLevPy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6afccc0bd6b03f036ae9e7b87f9446a70cf0752e7629398019ee589fe58fbd34
MD5 5fff197c36dba5bc9f95361cc7fb8550
BLAKE2b-256 e568422b896919ffe4c0e3eae32737b5326afee691873ea1cc42e2dc68eeb853

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page