ensemble_hic/setup_functions.py
def make_subsamplers(posterior, initial_state,
                     structures_hmc_params):
    """
    Makes a dictionary of (possibly MCMC) samplers for all variables

    :param posterior: posterior distribution you want to sample
    :type posterior: :class:`binf.pdf.posteriors.Posterior

    :param initial_state: intial state
    :type initial_state: :class:`binf.samplers.BinfState`

    :param structures_hmc_params: settings for the structures HMC
                                  sampler as specified in a config file
    :type structures_hmc_params: dict

    :returns: a dictionary with the keys being the variables and
              the values the corresponding samplers over which
              a Gibbs sampler eventually will iterate
    :rtype: dict
    """
    from binf.samplers.hmc import HMCSampler

    p = posterior
    variables = initial_state.keys()
    structures_tl = int(structures_hmc_params['trajectory_length'])
    structures_timestep = float(structures_hmc_params['timestep'])
    s_adaption_limit = int(structures_hmc_params['adaption_limit'])

    xpdf = p.conditional_factory(**{var: value for (var, value)
                                    in initial_state.iteritems()
                                    if not var == 'structures'})
    structures_sampler = HMCSampler(xpdf,
                                    initial_state['structures'],
                                    structures_timestep, structures_tl,
                                    variable_name='structures',
                                    timestep_adaption_limit=s_adaption_limit)

    subsamplers = dict(structures=structures_sampler)

    if 'norm' in variables:
        from .error_models import PoissonEM
        if isinstance(p.likelihoods['ensemble_contacts'].error_model,
                      PoissonEM):
            from .npsamplers import NormGammaSampler
            norm_sampler = NormGammaSampler()
            subsamplers.update(norm=norm_sampler)
        else:
            raise NotImplementedError('Norm sampling only implemented' +
                                      'for Poisson error model!')

    return subsamplers

    Makes a dictionary of (possibly MCMC) samplers for all variables

    :param posterior: posterior distribution you want to sample
    :type posterior: :class:`binf.pdf.posteriors.Posterior

    :param initial_state: intial state
    :type initial_state: :class:`binf.samplers.BinfState`

    :param structures_hmc_params: settings for the structures HMC
                                  sampler as specified in a config file
    :type structures_hmc_params: dict

    :returns: a dictionary with the keys being the variables and
              the values the corresponding samplers over which
              a Gibbs sampler eventually will iterate
    :rtype: dict
    
Makes a dictionary of (possibly MCMC) samplers for all variables
Makes a dictionary of ( possibly MCMC ) samplers for all variables
def make_subsamplers(posterior, initial_state,
                     structures_hmc_params):
    from binf.samplers.hmc import HMCSampler
    p = posterior
    variables = initial_state.keys()
    structures_tl = int(structures_hmc_params['trajectory_length'])
    structures_timestep = float(structures_hmc_params['timestep'])
    s_adaption_limit = int(structures_hmc_params['adaption_limit'])
    xpdf = p.conditional_factory(**{var: value for (var, value)
                                    in initial_state.iteritems()
                                    if not var == 'structures'})
    structures_sampler = HMCSampler(xpdf,
                                    initial_state['structures'],
                                    structures_timestep, structures_tl,
                                    variable_name='structures',
                                    timestep_adaption_limit=s_adaption_limit)
    subsamplers = dict(structures=structures_sampler)
    if 'norm' in variables:
        from .error_models import PoissonEM
        if isinstance(p.likelihoods['ensemble_contacts'].error_model,
                      PoissonEM):
            from .npsamplers import NormGammaSampler
            norm_sampler = NormGammaSampler()
            subsamplers.update(norm=norm_sampler)
        else:
            raise NotImplementedError('Norm sampling only implemented' +
                                      'for Poisson error model!')
    return subsamplers
def make_subsamplers ( posterior , initial_state , structures_hmc_params ) : from binf . samplers . hmc import HMCSampler p = posterior variables = initial_state . keys ( ) structures_tl = int ( structures_hmc_params [ 'trajectory_length' ] ) structures_timestep = float ( structures_hmc_params [ 'timestep' ] ) s_adaption_limit = int ( structures_hmc_params [ 'adaption_limit' ] ) xpdf = p . conditional_factory ( ** { var : value for ( var , value ) in initial_state . iteritems ( ) if not var == 'structures' } ) structures_sampler = HMCSampler ( xpdf , initial_state [ 'structures' ] , structures_timestep , structures_tl , variable_name = 'structures' , timestep_adaption_limit = s_adaption_limit ) subsamplers = dict ( structures = structures_sampler ) if 'norm' in variables : from . error_models import PoissonEM if isinstance ( p . likelihoods [ 'ensemble_contacts' ] . error_model , PoissonEM ) : from . npsamplers import NormGammaSampler norm_sampler = NormGammaSampler ( ) subsamplers . update ( norm = norm_sampler ) else : raise NotImplementedError ( 'Norm sampling only implemented' + 'for Poisson error model!' ) return subsamplers
Makes a dictionary of (possibly MCMC) samplers for all variables
Makes a dictionary of ( possibly MCMC ) samplers for all variables
"""
    Makes a dictionary of (possibly MCMC) samplers for all variables

    :param posterior: posterior distribution you want to sample
    :type posterior: :class:`binf.pdf.posteriors.Posterior

    :param initial_state: intial state
    :type initial_state: :class:`binf.samplers.BinfState`

    :param structures_hmc_params: settings for the structures HMC
                                  sampler as specified in a config file
    :type structures_hmc_params: dict

    :returns: a dictionary with the keys being the variables and
              the values the corresponding samplers over which
              a Gibbs sampler eventually will iterate
    :rtype: dict
    """
a dictionary with the keys being the variables and
the values the corresponding samplers over which
a Gibbs sampler eventually will iterate
a dictionary with the keys being the variables and the values the corresponding samplers over which a Gibbs sampler eventually will iterate
dict
posterior
posterior distribution you want to sample
posterior distribution you want to sample
initial_state
None
structures_hmc_params
settings for the structures HMC
sampler as specified in a config file
settings for the structures HMC sampler as specified in a config file