Giter VIP home page Giter VIP logo

s01's Introduction

random walk

Simulations of various types of random walk.

  • Simple random walks

    • Random walk on regular 1D lattice where you can step in any of the two directions {↑, ↓} with the same probability.
    • Random walk on regular 2D lattice where you can step in any of the four directions {↑, ←, ↓, →} with the same probability.
    • Random walk on regular 3D lattice where you can step in any of the six directions {↑, ←, ↙, ↓, →, ↗} with the same probability.
  • Restricted random walks

    • Random walk on regular 1/2/3D lattice without immediate return where you can step in three possible directions with the same probability, the first step is in any direction.
    • Random walk on the square lattice without crossing i.e. self-avoiding random walk.

Examples

Simple random walks

Restricted random walks

Random walk statistics

Build and run

All outputs such as data and images are located in output folder. The presented images were produced by Python implementation.

See the source files:

Python

You need Python version 3.10+.

Create a virtual environment.

py -3.10 -m venv .venv
.venv\scripts\activate
pip install matplotlib seaborn numpy pandas

Note: On Ubuntu may need to install venv module as sudo apt-get install python-venv. And invoke the module as python3 -m venv .venv (there is no py.exe as on Windows. Please read the official documentation.

Run the simulations.

python .\source\random_walk.py 1_000_000 3 123321 True # 1D simulation with 100_000 steps
                                                   ^------ Run solution (example) (True | False)
                                           ^-------------- Random seed
                                         ^---------------- Dimension (1 | 2 | 3)
                                ^------------------------- Number of steps per walk

The running simulation looks like this:

Run 2D example with statistics: from 1 to 500 steps and 100 repeats per steps.
trial = 218, walk = 990

… after succes run:

---SUCCESS---

Fortran

Work-in-progress: The Fortran version is almost finished, but data are not at the shape suitable for analysis.

Compile and run main program:

gfortran source\random_walk.f90 source\random_walk_main.f90 -o build\random_walk_main.exe
.\random_walk_main.exe 123 100 1 > data.psv

Compile and run test program:

gfortran source\random_walk.f90 source\random_walk_test.f90 -o build\random_walk_test.exe
.\build\random_walk_test.exe

Also, you can execute the project.bat with build command and then run programs:

.\project.bat build

.\build\random_walk_main.exe 123 100 1
.\build\random_walk_test.exe

s01's People

Contributors

4e1e0603 avatar ondrolexa avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

ondrolexa

s01's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.