nems.priors module

nems.priors._get_module_prior(module, default_priors={'nems.modules.fir.basic': {'coefficients': ('Normal', {'mean': [0], 'sd': [1]})}, 'nems.modules.levelshift.levelshift': {'level': ('Normal', {'mu': [0], 'sd': [10]})}, 'nems.modules.nonlinearity.double_exponential': {'amplitude': ('Normal', {'mu': [0.2], 'sd': [1]}), 'base': ('Normal', {'mean': [0], 'sd': [1]}), 'kappa': ('Normal', {'mean': [0], 'sd': [0.1]}), 'shift': ('Normal', {'mean': [0], 'sd': [1]})}})[source]

Returns the prior distributions for a module. If a ‘prior’ field exists in module, its distributions are used to replace any default priors listed in keywords/default_priors.

nems.priors._to_phi(prior, method='mean', percentile=50)[source]

Not for public use. Sample from a single module prior; method must be ‘mean’, ‘sample’, or ‘percentile’. Returns a dict of parameters suitable for use as ‘phi’.

nems.priors._set_phi_in_module(module, prior_to_phi_fn)[source]

Not for public use. Returns a module identical to the one provided, but with phi initalized using the priors.

nems.priors._set_phi_in_modelspec(modelspec, prior_to_phi_fn)[source]

Not for public use. Initializes phi for each module in the modelspec, if one does not already exist for each module.


Returns a modelspec with phi set to the expected values of priors.


Returns a modelspec with phi set to random samples from the priors.

nems.priors.set_percentile_phi(modelspec, percentile)[source]

Returns a modelspec with phi set to what falls at the given percentile of the Cumulative Density Function (CDF) of each module’s parameters.

Note: Because our priors are not a joint probability distribution, if you have 2 independent parameters and use the 10% percentile, this means the 10% percentile on each one, giving you the 0.10 * 0.10 = 0.01 or 1% percentile joint prob sample. In other words, this is fine for bounds plotting or CI, but if you really want the joint distribution percentile, CDF you will need to rescale percentile accordingly. TODO.

nems.priors.set_percentile_bounds(modelspec, lower_percentile, upper_percentile)[source]