Skip to main content

Super Brownian Motion Simulation

Super Brownian Motion

Introduction

This Python script simulates super Brownian Motion (SBm), a stochastic process where particles move randomly and branch under certain conditions. The script offers functionalities to simulate the motion, plot the paths, save the images, export the data, and generate an animation of the process in the gif format.

  • Currently, all paths will branch or die after every fixed number of steps (default 100). More flexibility will be added in the future.

Requirements

  • Python 3
  • NumPy
  • Matplotlib

Installation

Ensure you have Python 3 installed. You can install the required packages using pip:

pip install git+https://github.com/yourusername/mypackage.git

or from pypi

pip install simulation-super-brownian-motions

Usage

Command line

To run the simulation with default parameters, simply execute the script:

SuperBm --help

Command Line Arguments

You can customize the simulation using the following command line arguments:

  • -s or --seed: Random seed (default: 42), set to -1 for random seed based on current time (for random outcome)
  • -n or --num-steps: Number of steps in the simulation (default: 301)
  • -u or --update-steps: Number of steps between branching events (default: 100)
  • -p or --branching-prob: Probability of branching at each step (default: 0.5)
  • -c or --scale: Scale of the Brownian motion (default: 10.0)
  • -d or --dpi: DPI parameter for the animation (default: 150)
  • -a or --save-animation: Save the animation as a GIF

Example

SuperBm --num-steps 500 --branching-prob 0.7 --scale 15

This command runs the simulation with 500 steps, a branching probability of 0.7, a Brownian motion scale of 15, and with default values for the other parameters. The animation won't be saved as a GIF.

If you want the animation, run the following command:

SuperBm --num-steps 500 --branching-prob 0.7 --scale 15 --save-animation

Output

  • The script will plot the paths of the Brownian motion.
  • Paths will be exported as a CSV file.
  • The plot will be saved as files in both PNG and JPET formats.
  • With additional argument -a or --save-animation, the script will generate an animation of the process and save it as a GIF file.

Within Python as a Module

You can use the script within Python as a module. The following example shows how to run the simulation with default parameters:

import simulation_super_brownian_motions.super_bm_simulation as sbm

# Create an instance of the class
instance = sbm.Branching_BM()

# Use the instance and its methods
instance.simulate()
instance.plot_paths()

Contributing

Contributions to this project are welcome! Please feel free to submit pull requests or open issues to discuss potential improvements or features.

Acknowledgments

Thanks for helpful discussions with Yumin Zhong and Panqiu Xia from Auburn University.

License

Metadata

Release files for simulation-super-brownian-motions 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simulation-super-brownian-motions 1.2.3
File Size Uploaded
simulation_super_brownian_motions-1.2.3.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for simulation-super-brownian-motions 1.2.3
File Interpreter ABI Platform
simulation_super_brownian_motions-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / simulation_super_brownian_motions-1.2.3.tar.gz

Download URL simulation_super_brownian_motions-1.2.3.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3e78ccf546cc5098461cb2254769fe72c7ca3c67e2063e07babe63957468f1b6
BLAKE2b-256 checksum
How to use checksums
af360540e1b0550ad38a0152c779acd36a3661bf35f7f2f3d48b726f5ec560d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / simulation_super_brownian_motions-1.2.3-py3-none-any.whl

Download URL simulation_super_brownian_motions-1.2.3-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd16bd29e7098461418f8c60be049acb66f7af7908120824e61a6b2ee691ad82
BLAKE2b-256 checksum
How to use checksums
06d71304e2fe419d6ce5fcc5bb56cbd32b6f5808e1d33dd38105fb792c851169
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page