https://github.com/ethanuppal/metropolis
An implementation of the Metropolis algorithm.
https://github.com/ethanuppal/metropolis
bayesian monte-carlo statistics
Last synced: 11 months ago
JSON representation
An implementation of the Metropolis algorithm.
- Host: GitHub
- URL: https://github.com/ethanuppal/metropolis
- Owner: ethanuppal
- Created: 2023-04-21T02:36:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-21T02:36:24.000Z (about 3 years ago)
- Last Synced: 2024-01-29T23:11:26.337Z (over 2 years ago)
- Topics: bayesian, monte-carlo, statistics
- Language: Swift
- Homepage:
- Size: 200 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# metropolis
This repository contains my implementation of the [Metropolis algorithm](src/MCMC/Metropolis.swift), which is used for Bayesian statistical analysis, as well as a [custom graph renderer](src/Graphics/Graph.swift). Here is example output from a run of the program.

```
Bayesian Analysis
using Markov chain Monte Carlo
==============================
Observations
------------
- 2 coin flips
- 1 head(s)
Prior
-----
We use an uninformed prior: beta(a=1, b=1)
Likelihood
----------
P(data|θ) = bernoulli(N=2, z=1)
Metropolis
----------
We perform the metropolis algorithm to estimate the central tendency of the posterior distribution.
Random seed: 0.834189865344514
Steps: 10000
Burn-in Period: 3000
Est. Mean: 0.4934783753798731
Est. StdDev: 0.22304677011859197
Actual
------
P(θ|data) = beta(a=2, b=2)
Act. Mean: 0.5 (-1.0% error)
Act. StdDev: 0.22360679774997896 (-0.0% error)
```