-
Notifications
You must be signed in to change notification settings - Fork 6
Fitting algorithm
Romesh Abeysuriya edited this page Oct 22, 2015
·
9 revisions
This page contains information about the fit wrappers
- fit spectrum
- fit
- fit track
- fit cluster
Detailed information about the fitting process is provided here. At a high level, there are three primary uses for BrainTrak
- Computation of the random walk and generation of the chain is performed by
chain.m
andchain_parallel.m
- A minimal fit is generated by
fit_spectrum.m
which callschain.m
. This function takes in a spectrum
Typically, you would not use the core functions directly. Instead, you would write other scripts and functions that use these core routines. For example
-
+bt/fit.m
shows a minimal fitting example, taking in a model, a spectrum, and optionally the length of the chain (i.e., how long to run the routine for) -
+bt/fit_track.m
shows common usage of BrainTrak, where a data set is automatically loaded and preprocessed, and then a sequence of spectra is fitted with incremental prior updates.
Additional wrappers for these routines are provided in braintrak/data_examples
(for fitting various data sets), and braintrak/published/Abeysuriya_2015
which contains wrappers used to generate the fits published in Abeysuriya (2015).
MCMC fitting consists of the following steps
- Get some initial parameter values (manually specified, or automatically given by
model.initialize_fit
) -
Simulate a random walk (
chain.m
) - Pick the most likely parameters (
fit.m
) - Compute the posterior marginal distributions (
model.make_posterior
)
These steps are all driven by fit.m
. The steps in fit.m
are
- You specify the model, the target power spectrum, and the priors and initial conditions. If you don't have any priors or initial conditions e.g., because this is the first fit in a series of fits, you should use
model.initialize_fit
beforehand, like infit_single.m
-
model.prepare_for_fit
is called, which loads the power spectrum into the model object and callsmodel.set_cache
to do any one-off computations - The chain is simulated using
mcmc.chain
ormcmc.chain_parallel
depending on whether aparpool
is open - The output from the chain is analyzed, producing the
fit_data
struct which stores information about the posteriors and the optimum fit, andplot_data
struct which contains the XYZ cloud data (only used for plotting)