Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.37 KB

howtoutilities.rst

File metadata and controls

37 lines (27 loc) · 1.37 KB

How to write a new utility routine

In this tutorial, we describe how to include a new utility (specifically, a sampler) to the surmise's framework. We illustrate this with metropolis_hastings--a well-known sampler located in the directory \utilitiesmethods.

In surmise, all utilities inherit from the base class :pysurmise.utilities.sampler. Note that for now, we only have samplers as utilities. Later, we plan to have different classes (such as :pysurmise.utilities.optimizer) that can be used during calibration.

A sampler takes the function returning the log of the posterior of given theta as an input, and returns a dictionary including a random sample of thetas from the posterior distribution.

Mandatory functions

:pysampler is the only obligatory function for a sampler.

The :pymetropolis_hastings.sampler is given below for an illustration:

metropolis_hastings

Once the base class :pysurmise.utilities.sampler is initialized, :pysurmise.utilities.sampler.draw_samples method calls the developer's sampler's :pysampler function, and places all information into the dictionary, and returns it.

Optional functions

None. This section is under development.