pymcmcstat.structures package

pymcmcstat.structures.ParameterSet module

Created on Thu Jan 18 10:15:37 2018

@author: prmiles

class pymcmcstat.structures.ParameterSet.ParameterSet(theta=None, ss=None, prior=None, sigma2=None, alpha=None)[source]

Bases: object

Basic MCMC parameter set.

Description: Storage device for passing parameter sets back and forth between sampling methods.

Args:
  • theta (ndarray): Sampled values.
  • ss (ndarray): Sum-of-squares error(s).
  • prior (ndarray): Result from prior function.
  • sigma2 (ndarray): Observation errors.
  • alpha (float): Result from evaluating likelihood function.

pymcmcstat.structures.ResultsStructure module

Created on Wed Jan 17 09:18:19 2018

@author: prmiles

class pymcmcstat.structures.ResultsStructure.ResultsStructure[source]

Bases: object

Results from MCMC simulation.

Description: Class used to organize results of MCMC simulation.

Attributes:
add_basic(nsimu, covariance, parameters, rejected, simutime, theta)[source]

Add basic results from MCMC simulation to structure.

Args:
add_chain(chain=None)[source]

Add chain to results structure.

Args:
  • chain (ndarray): Model parameter sampling chain.
add_dram(drscale, RDR, total_rejected, drsettings)[source]

Add results specific to performing DR algorithm.

Args:
  • drscale (ndarray): Reduced scale for sampling in DR algorithm. Default is [5,4,3].
  • RDR (ndarray): Cholesky decomposition of covariance matrix based on DR.
  • total_rejected (int): Number of rejected samples.
  • drsettings (DelayedRejection): Need access to counters within DR class.
add_model(model=None)[source]

Saves subset of features of the model settings in a nested dictionary.

Args:
add_options(options=None)[source]

Saves subset of features of the simulation options in a nested dictionary.

Args:
add_prior(mu, sigma, priortype)[source]

Add results specific to prior function.

Args:
  • mu (ndarray): Prior mean.
  • sigma (ndarray): Prior standard deviation.
  • priortype (int): Flag identifying type of prior.

Note

This feature is not currently implemented.

add_random_number_sequence(rndseq)[source]

Add random number sequence to results structure.

Args:
  • rndseq (ndarray): Sequence of sampled random numbers.

Note

This feature is not currently implemented.

add_s2chain(s2chain=None)[source]

Add observiation error chain to results structure.

Args:
  • s2chain (ndarray): Sampling chain of observation errors.
add_sschain(sschain=None)[source]

Add sum-of-squares chain to results structure.

Args:
  • sschain (ndarray): Calculated sum-of-squares error for each parameter chains set.
add_time_stats(mtime, drtime, adtime)[source]

Add time spend using each sampling algorithm.

Args:
  • mtime (float): Time spent performing standard Metropolis.
  • drtime (float): Time spent performing Delayed Rejection.
  • adtime (float): Time spent performing Adaptation.

Note

This feature is not currently implemented.

add_updatesigma(updatesigma, sigma2, S20, N0)[source]

Add information to results structure related to observation error.

Args:
  • updatesigma (bool): Flag to update error variance(s).
  • sigma2 (ndarray): Latest estimate of error variance(s).
  • S20 (ndarray): Scaling parameter(s).
  • N0 (ndarray): Shape parameter(s).

If updatesigma is True, then

results['sigma2'] = np.nan
results['S20'] = S20
results['N0'] = N0

Otherwise

results['sigma2'] = sigma2
results['S20'] = np.nan
results['N0'] = np.nan
classmethod determine_filename(options)[source]

Determine results filename.

If not specified by results_filename in the simulation options, then a default naming format is generated using the date string associated with the initialization of the simulation.

Args:
Returns:
  • filename (str): Filename string.
export_simulation_results_to_json_file(results)[source]

Export simulation results to a json file.

Args:
classmethod load_json_object(filename)[source]

Load object stored in json file.

Note

Filename should include extension.

Args:
  • filename (str): Load object from file with this name.
Returns:
  • results (dict): Object loaded from file.
classmethod save_json_object(results, filename)[source]

Save object to json file.

Note

Filename should include extension.

Args:
  • results (dict): Object to save.
  • filename (str): Write object into file with this name.