Package trunk :: Package BIP :: Package Bayes :: Package Samplers :: Module MCMC :: Class Metropolis
[hide private]

Class Metropolis

source code

object --+    
         |    
  _Sampler --+
             |
            Metropolis

Standard random-walk Metropolis Hastings sampler class
Instance Methods [hide private]
 
__init__(self, meldobj, samples, sampmax, data, t, parpriors, parnames, parlimits, likfun, likvariance, burnin, **kwargs)
MCMC based fitting
source code
 
_propose(self, step, po=None)
Generates proposals. returns two lists
source code
 
step(self, nchains=1)
Does the actual sampling loop.
source code
 
_rms_fit(self, s1, s2)
Calculates a basic fitness calculation between a model- generated time series and a observed time series. It uses a normalized RMS variation.
source code
 
_imp_sample(self, n, data, w)
Importance sampling
source code
 
_add_salt(self, dataset, band)
Adds a few extra uniformly distributed data points beyond the dataset range. This is done by adding from a uniform dist.
source code

Inherited from _Sampler: DIC, best_prop_index, check_constraints, dimensions, gr_R, gr_convergence, po, setup_xmlrpc_plotserver, shut_down, shutdown_xmlrpc_plotserver, term_pool

Inherited from _Sampler (private): _accept, _every_plot, _tune_likvar, _watch_chain

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from _Sampler: e, liklist, seqhist, trace_acceptance, trace_convergence

Inherited from _Sampler (private): _R, _dimensions, _j, _po

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, meldobj, samples, sampmax, data, t, parpriors, parnames, parlimits, likfun, likvariance, burnin, **kwargs)
(Constructor)

source code 
MCMC based fitting
Parameters:
  • samples - : Number of samples to obtain
  • sampmax - : Maximum number of samples drawn.
  • data - : observed time series on the model's output
  • t - : length of the observed time series
  • parpriors - : Dictionary with frozen distributions objects as values and parnames as keys
  • parnames - : List of parameter names
  • parlimits - : list of tuples with (min,max) for every parameter.
  • likfun - : Likelihood function
  • likvariance - : variance of the Normal likelihood function
  • burnin - : Number of burnin samples
Overrides: object.__init__

_propose(self, step, po=None)

source code 
Generates proposals. returns two lists
Parameters:
  • step - : Position in the markov chain history.
  • po - : Process pool for parallel proposal generation
Returns:
  • theta: List of proposed self.dimensional points in parameter space
  • prop: List of self.nchains proposed phis.
Overrides: _Sampler._propose

_rms_fit(self, s1, s2)

source code 

Calculates a basic fitness calculation between a model- generated time series and a observed time series. It uses a normalized RMS variation.

s1 and s2 can also be both lists of lists or lists of arrays of the same length.

Parameters:
  • s1 (: Record array or list.) - : model-generated time series.
  • s2 (: Dictionary or list) - : observed time series. dictionary with keys matching names of s1
Returns:
Inverse of the Root mean square deviation between s1 and s2.

_imp_sample(self, n, data, w)

source code 
Importance sampling
Parameters:
  • n - : Number of samples to return
  • data - : record array (containing on or more vectors of data) to be resampled
  • w - : Weight vector
Returns:
returns a sample of size n

_add_salt(self, dataset, band)

source code 
Adds a few extra uniformly distributed data points beyond the dataset range. This is done by adding from a uniform dist.
Parameters:
  • dataset - : vector of data
  • band - : Fraction of range to extend: [0,1[
Returns:
Salted dataset.