Skip to content
/ pksd Public

Code for the paper "Using Perturbation to Improve Goodness-of-Fit Tests based on Kernelized Stein Discrepancy".

License

Notifications You must be signed in to change notification settings

XingLLiu/pksd

Repository files navigation

Code for pKSD

Paper | Poster

How to install?

Install as a package

Before running any scripts, run the following to install the current package and the dependencies. Packages that this programme depends on are listed in setup.py.

  1. Run the follwing to install the this repo as a package called pksd.
pip install git+https://github.com/XingLLiu/pksd.git
  1. Run the following to install the kgof package for the implementation of the FSSD test (Jitkrittum et al., 2017. An interpretable linear-time kernel goodness-of-fit test), which is required by our package.
pip install git+https://github.com/wittawatj/kernel-gof.git

Code for KSDAgg (Schrab et al., 2022. KSD Aggregated Goodness-of-fit Test) is copied from this Github repo and held in pksd/kgof, and hence it does not require installation. This is to customise the output of their test so that results can be copmared with the other tests.

Install dependencies only

Alternatively, to install only the dependencies but not as a package, run

pip install -r requirements.txt

Examples

This package can be loaded as a python module with

import pksd

See example_gaussian_mix.ipynb for an example of how to use the spKSD and ospKSD tests for a given target distribution and a given sample. All dependencies must be installed beforehand following the instruction in "How to install?".

To reproduce the results in the paper, run e.g.,

# mixture of two gaussians example
sh sh_scripts/run_bimodal.sh

Results will be stored in res/bimodal. Other experiments can be reproduced similarly by changing run_bimodal.sh to run_rbm.sh, run_t-banana.sh or run_sensors.sh.

Folder structure

.
├── pksd                          # Source files for pKSD and benchmarks
├── sh_scripts                    # Shell scripts to run experiments
├── res                           # Folder to store results
├── figs                          # Folder to store figures
├── experiments.py                # Main script for generating results
├── experiment_sensor.py          # Main script for running the sensor localisation example
├── example_gaussian_mix.ipynb    # Demonstration for how to use the pKSD tests (spKSD and ospKSD) and code for producing the thumbnail
├── setup.py                      # Setup file for easy-install of pKSD
└── README.md

About

Code for the paper "Using Perturbation to Improve Goodness-of-Fit Tests based on Kernelized Stein Discrepancy".

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors