Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreas-bauer/monte-carlo-sim
Markov Chain Monte Carlo (MCMC) Simulation with Metropolis Algorithm
https://github.com/andreas-bauer/monte-carlo-sim
Last synced: 3 months ago
JSON representation
Markov Chain Monte Carlo (MCMC) Simulation with Metropolis Algorithm
- Host: GitHub
- URL: https://github.com/andreas-bauer/monte-carlo-sim
- Owner: andreas-bauer
- License: mit
- Created: 2022-03-19T18:00:49.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T08:14:14.000Z (about 1 year ago)
- Last Synced: 2023-12-04T09:25:20.185Z (about 1 year ago)
- Language: Go
- Size: 2.09 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Markov Chain Monte Carlo (MCMC) Simulation with Metropolis Algorithm
## Introduction
This is an implementation of the MCMC simulation with Metropolis algorithm example from the Statistical Rethinking [1] book (chapter 9.1 page 265) in Go.
King Markov wants to visit every 10 islands of his kingdom regularly.
He wants to visit islands were with a bigger population and therefore with more people who love him more often than smaller islands.
The second island is twice as popular as the first, the third is three times as popular as the first, and so on.
Using MCMC allows the king to visit the islands depending on the popularity without scheduling every trip in advance.### References
[1] McElreath, R. (2020). Statistical rethinking: A Bayesian course with examples in R and Stan. Chapman and Hall/CRC.
## Run Simulation
`go run ./main.go` creates a `barchart.png` as shown in the result section.
You can change the vars `numWeeks` and `numIslands` to adjust the simulation. But plotting is only possible for 10 islands.
## Results
This is the resulting bar chart after 100000 (1e5) weeks.
![Simulation](1e5_weeks.png)
## License
Copyright © 2022-2023 Andreas Bauer
This work (source code) is licensed under [MIT](./LICENSE).
Logo is generated with DALL·E 3.