holopy.inference package

Module contents

holopy.inference.noise_model module

class AlphaModel(scatterer, noise_sd, alpha, medium_index=None, illum_wavelen=None, illum_polarization=None, theory='auto')

Bases: holopy.inference.noise_model.NoiseModel

class NoiseModel(scatterer, noise_sd, medium_index=None, illum_wavelen=None, illum_polarization=None, theory='auto')

Bases: holopy.fitting.model.BaseModel

Model probabilites of observing data

Compute probabilities that observed data could be explained by a set of scatterer and observation parameters.

lnlike(par_vals, data)
lnposterior(par_vals, data)
lnprior(par_vals)

holopy.inference.prior module

class BoundedGaussian(mu, sd, lower_bound=-inf, upper_bound=inf, name=None)

Bases: holopy.inference.prior.Gaussian

lnprob(p)
sample(size=None)
class Gaussian(mu, sd, name=None)

Bases: holopy.inference.prior.Prior

guess
lnprob(p)
prob(p)
sample(size=None)
class Prior(guess=None, limit=None, name=None, **kwargs)

Bases: holopy.fitting.parameter.Parameter

class Uniform(lower_bound, upper_bound, name=None)

Bases: holopy.inference.prior.Prior

guess
interval
lnprob(p)
sample(size=None)
make_center_priors(im, z_range_extents=5, xy_uncertainty_pixels=1, z_range_units=None)

Make sensible default priors for the center of a sphere in a hologram

Parameters:
  • im (xarray) – The image you wish to make priors for
  • z_range_extents (float (optional)) – What range to extend a uniform prior for z over, measured in multiples of the total extent of the image. The default is 5 times the extent of the image, a large range, but since tempering is quite good at refining this, it is safer to just choose a large range to be sure to include the correct value.
  • xy_uncertainty_pixels (float (optional)) – The number of pixels of uncertainty to assume for the centerfinder. The default is 1 pixel, and this is probably correct for most images.
  • z_range_units (float) – Specify the range of the z prior in your data units. If this is provided, z_range_extents is ignored.
updated(prior, v, extra_uncertainty=0)

Update a prior from a posterior

Parameters:
  • v (UncertainValue) – The new value, usually from an mcmc result
  • extra_uncertainty (float) – provide a floor for uncertainty (sd) of the new parameter

holopy.inference.result module

Results of sampling

class SamplingResult(dataset, model, strategy)

Bases: holopy.core.holopy_object.HoloPyObject

MAP
data
lnprobs
mean
median
samples
sigma_intervals(sigmas=[-2, -1, 1, 2])
values(sigma_interval=1)
class TemperedSamplingResult(end_result, stage_results, strategy)

Bases: holopy.inference.result.SamplingResult

dataset
model
class UncertainValue(value, plus, minus=None, n_sigma=1, kind='MAP')

Bases: holopy.core.holopy_object.HoloPyObject

Represent an uncertain value

Parameters:
  • value (float) – The value
  • plus (float) – The plus n_sigma uncertainty (or the uncertainty if it is symmetric)
  • minus (float or None) – The minus n_sigma uncertainty, or None if the uncertainty is symmetric
  • n_sigma (int (or float)) – The number of sigma the uncertainties represent
autocorr_from_sentinal(d)
autocorr_to_sentinal(d)
get_stage_names(inf)

holopy.inference.sample module

Sample posterior probabilities given model and data

class EmceeStrategy(nwalkers=100, pixels=2000, threads='auto', cleanup_threads=True, seed=None)

Bases: holopy.core.holopy_object.HoloPyObject

make_guess(parameters)
sample(model, data, nsamples, walker_initial_pos=None)
class TemperedStrategy(next_initial_dist=<function sample_one_sigma_gaussian>, nwalkers=100, min_pixels=50, max_pixels=1000, threads='auto', stages=3, stage_len=30, seed=None)

Bases: holopy.inference.sample.EmceeStrategy

sample(model, data, nsamples)
autothreads(threads='auto', quiet=False)
emcee_lnprobs_DataArray(sampler)
emcee_samples_DataArray(sampler, parameters)
get_acor(sampler)
sample_emcee(model, data, nwalkers, nsamples, walker_initial_pos, threads='auto', cleanup_threads=True, seed=None)
sample_emcee_autocorr(model, data, nwalkers, independent_samples, walker_initial_pos, estimated_autocorr, threads='auto')
sample_one_sigma_gaussian(result)
tempered_sample(model, data, nwalkers=100, min_pixels=50, max_pixels=2000, samples=600, next_initial_dist=<function sample_one_sigma_gaussian>, stages=3, stage_len=30, seed=None, threads='auto')