This project implements a Markov Chain Monte Carlo method -- specifically the Metropolis-Hastings algorithm to identify Gravitational wave-like signals from noisy time series data. It uses simulated data containing a gravitational wave–like signal with added noise.
We aim to recover the parameters α, β, and γ of the analytical model that describes the signal:
- α controls the amplitude of the signal
- β shifts the signal in time
- γ controls the oscillation frequency
The parameters vary within these ranges:
We perform a random walk in the 3D parameter space:
using the Metropolis–Hastings algorithm to sample from the posterior probability distribution:
The prior
The likelihood is calculated as:
where
The error at each data point is assumed to be 20%. (given)
Each iteration proposes a new set of parameters. If the new parameters give a higher probability, they are accepted; otherwise, they may still be accepted with a probability proportional to their likelihood ratio.
This helps the algorithm explore the entire parameter space instead of getting stuck in local maxima.
The program estimates the most likely values of α, β, and γ, and also provides uncertainty ranges.
We have plotted the following:
- Posterior distributions for each parameter
- A reconstructed signal overlaid on the noisy data
- Histograms or corner plots showing parameter correlations and convergence
| Alpha vs Beta | Beta vs Gamma | Gamma vs Alpha |
|---|---|---|
![]() |
![]() |
![]() |
The algorithm ran with an acceptance rate of
The predicted parameters are:
| Parameter | Alpha |
Beta |
Gamma |
|---|---|---|---|
| Median Value | |||
| 95% Interval |
The model graph using the predicted parameters is shown in the image above and Results/Original_Unknown/Gravitational_Wave_pred.png
- Metropolis–Hastings algorithm (MCMC sampling)
- Bayesian inference
- Parameter estimation under noise
- Gravitational wave signal modeling
Gravity-Wave-Identification/
├── main.py # Main orchestrator with mode routing
├── run.sh # Bash launcher for interactive execution
├── gw_data.csv # Unknown gravitational wave data (problem input)
├── requirements.txt # Python dependencies (numpy, pandas, matplotlib, etc.)
├── README.md # Repository documentation
│
├── Configurations/ # Configuration and model definitions
│ ├── Grav_Wave.yaml # MCMC parameters for generated/unknown modes
│ ├── variance_test.yaml # MCMC parameters for variance testing
│ └── gw_functions.py # Gravitation_Wave class, likelihood functions
│
├── Source/ # Core algorithm and visualization
│ ├── metropolis_hasting.py # MetroHaste MCMC implementation
│ └── plotting.py # Visualization functions (histogram_gw, corner_plot, etc.)
│
├── Data_Gen/ # Data generation pipeline
│ ├── generator.py # Generate_Data function
│ └── Data_Grav_Wave.csv # Synthetic noisy data (generated mode output)
│
├── Results/ # Output directory for experiments
│ ├── [experiment_id]/ # Custom experiment outputs (generated mode)
│ │ ├── Gravitational_Wave_data.png
│ │ ├── Gravitational_Wave_pred.png
│ │ ├── MH_hist.png
│ │ └── Covariance/ # Alpha_vs_Beta.png, Beta_vs_Gamma.png, Gamma_vs_Alpha.png
│ ├── Original_Unknown/ # Unknown mode outputs
│ │ ├── Gravitational_Wave_pred.png
│ │ ├── Histogram.png
│ │ └── Covariance/ # Alpha_vs_Beta.png, Beta_vs_Gamma.png, Gamma_vs_Alpha.png
│ └── Variance_Test.png # Variance mode diagnostic plot
│ └── Likelih_Comparison.png # Comparison between Likelihood Functions
│
├── Typst_Presentation/ # Documentation and presentation
│ └── slides.typ # Typst source for scientific presentation
│
└── manim_animation/ # Parameter effect animations
- Clone the Repository
git clone https://github.com/Anirudh0616/Gravity-Wave-Identification.git
cd Gravity-Wave-Identification- Create and Activate Virtual Environment
# MacOS/Linux
python3 -m venv .venv
source .venv/bin/activate
# Windows ( Command Prompt )
py -3 -m venv .venv
..venv\Scripts\activate.bat- Install the dependencies
pip install -r requirements.txt- Run the Launcher
# MacOS/Linux
chmod +x run.sh
./run.sh
# Windows
bash run.shThe Launcher will prompt you to enter values for test experiment and experiment name ( Directory name for plots to be saved in )
- Deactivate afterwards
deactivate- Metropolis et al. (1953), Equation of State Calculations by Fast Computing Machines
- Hastings (1970), Monte Carlo Sampling Methods Using Markov Chains
- Gregory, P. C. (2005), Bayesian Logical Data Analysis for the Physical Sciences
- Charles Zaiontz, Effective Sample Size for Metropolis Algorithm
- Gareth O. Roberts, Jeffrey S. Rosenthal "General state space Markov chains and MCMC algorithms," Probability Surveys, Probab. Surveys 1(none), 20-71, (2004)
- Taboga, Marco (2021). "Metropolis-Hastings algorithm", Lectures on probability theory and mathematical statistics. Kindle Direct Publishing. Online appendix. StatLect MCMC Notes
This repository is our collective project for Dr. Kirit Makwana's Computational Physics EP4210 at IIT Hyderabad (Fall 2025)




