pyhrf.jde.beta.
BetaSampler
(do_sampling=True, use_true_value=False, val_ini=array([ 0.7]), sigma=0.05, pr_beta_cut=1.2, pf_method='es', pf=None)¶Bases: pyhrf.xmlio.Initable
, pyhrf.jde.samplerbase.GibbsSamplerVariable
checkAndSetInitValue
(variables)¶getOutputs
()¶get_string_value
(v)¶linkToData
(dataInput)¶loadBetaGrid
()¶parametersComments
= {'pf_method': 'either "es" (extrapolation scheme) or "ps" (path sampling)'}¶parametersToShow
= ['do_sampling', 'val_ini']¶sampleNextInternal
(variables)¶Define the behaviour of the variable at each sampling step when its sampling is not activated. Must be overriden in child classes.
samplingWarmUp
(variables)¶Called before the launch of the main sampling loop by the sampler engine. Should be overriden and perform precalculations.
saveCurrentValue
(it)¶pyhrf.jde.beta.
Cpt_AcceptNewBeta_Graph
(RefGraph, GraphNodesLabels, VecEstim_lnZ, VecBetaVal, CurrentBeta, sigma, thresh=1.2, GraphWeight=None)¶Starting from a given Beta vector (1 value for each condition) CurrentBeta, computes new Beta values in NewBeta using a Metropolis-Hastings step.
Parameters: |
|
---|---|
Returns: | Contains the accepted beta value at the next iteration |
Return type: | NewBeta |
pyhrf.jde.beta.
Cpt_Distrib_P_beta_graph
(RefGraph, GraphNodesLabels, VecEstim_lnZ, VecBetaVal, thresh=1.5, GraphWeight=None)¶Computes the distribution
Parameters: |
|
---|---|
Returns: | contains the values (consistent with VecBetaVal). |
Return type: | Vec_P_Beta |
pyhrf.jde.beta.
Cpt_Exact_lnZ_graph
(RefGraph, beta, LabelsNb, GraphWeight=None)¶Computes the logarithm of the exact partition function .
Parameters: |
|
---|---|
Returns: | exact value of ln(Z) |
Return type: | exact_lnZ |
pyhrf.jde.beta.
Cpt_Expected_U_graph
(RefGraph, beta, LabelsNb, SamplesNb, GraphWeight=None, GraphNodesLabels=None, GraphLinks=None, RefGrphNgbhPosi=None)¶Useless now!
Estimates the expectation of U for a given normalization constant Beta and a given mask shape. Swendsen-Wang sampling is used to assess the expectation on significant images depending of beta.
Parameters: |
|
---|---|
Returns: | U expectation |
Return type: | ExpectU |
pyhrf.jde.beta.
Cpt_Vec_Estim_lnZ_Graph
(RefGraph, LabelsNb, SamplesNb=40, BetaMax=1.4, BetaStep=0.05, GraphWeight=None)¶Estimates ln(Z) for fields of a given size and Beta values between 0 and BetaMax. Estimates of ln(Z) are first computed on a coarse grid of Beta values. They are then computed and returned on a fine grid. No approximation using precomputed partition function is performed here.
Parameters: |
|
---|---|
Returns: |
|
pyhrf.jde.beta.
Cpt_Vec_Estim_lnZ_Graph_fast
(RefGraph, LabelsNb, MaxErrorAllowed=5, BetaMax=1.4, BetaStep=0.05)¶Estimate ln(Z(beta)) of Potts fields. The default Beta grid is between 0. and 1.4 with a step of 0.05. Extrapolation algorithm is used. Fast estimates are only performed for Ising fields (2 labels). Reference partition functions were pre-computed on Ising fields designed on regular and non-regular grids. They all respect a 6-connectivity system.
Parameters: |
|
---|---|
Returns: |
|
pyhrf.jde.beta.
Cpt_Vec_Estim_lnZ_Graph_fast2
(RefGraph, BetaMax=1.4, BetaStep=0.05)¶Estimate ln(Z(beta)) of Ising fields (2 labels). The default Beta grid is between 0. and 1.4 with a step of 0.05. Bilinar estimation with the number of sites and cliques is used. The bilinear functions were estimated using bilinear regression on reference partition functions on 240 non-regular grids and with respect to a 6-connectivity system. (Pfs are found in LoadBaseLogPartFctRef -> PFs 0:239)
Parameters: |
|
---|---|
Returns: |
|
pyhrf.jde.beta.
Cpt_Vec_Estim_lnZ_Graph_fast3
(RefGraph, LabelsNb, MaxErrorAllowed=5, BetaMax=1.4, BetaStep=0.05)¶Estimate ln(Z(beta)) of Potts fields. The default Beta grid is between 0. and 1.4 with a step of 0.05. Extrapolation algorithm is used. Fast estimates are only performed for Ising fields (2 labels). Reference partition functions were pre-computed on Ising fields designed on regular and non-regular grids. They all respect a 6-connectivity system.
Parameters: |
|
---|---|
Returns: |
|
pyhrf.jde.beta.
Cpt_Vec_Estim_lnZ_OLD_Graph
(RefGraph, LabelsNb, SamplesNb=50, BetaMax=1.0, BetaStep=0.01, GraphWeight=None)¶Useless now!
Estimates ln(Z) for fields of a given size and Beta values between 0 and BetaMax.
Parameters: |
|
---|---|
Returns: |
|
pyhrf.jde.beta.
Cpt_Vec_Estim_lnZ_Onsager
(n, BetaMax=1.2, BetaStep=0.05)¶Estimate ln(Z(beta)) Onsager using Onsager technique (2D periodic fields - 2 labels - 4 connectivity)
Parameters: |
|
---|---|
Returns: |
|
pyhrf.jde.beta.
Estim_lnZ_Onsager
(n, beta)¶Estimate ln(Z(beta)) using Onsager technique (2D periodic fields - 2 labels - 4 connectivity)
Parameters: |
|
---|---|
Returns: | ln(Z(beta)) estimate |
Return type: | LogZ |
pyhrf.jde.beta.
Estim_lnZ_ngbhd_graph
(RefGraph, beta_Ngbhd, beta_Ref, lnZ_ref, VecU_ref, LabelsNb)¶Estimates ln(Z) for beta=betaNgbhd. beta_Ngbhd is supposed close to beta_Ref for which ln(Z) is known (lnZ_ref) and the energy U of fields generated according to it have already been computed (VecU_ref).
Parameters: |
|
---|---|
Returns: | ln(Z) for beta=beta_Ngbhd |
Return type: | lnZ_Ngbhd |
pyhrf.jde.beta.
LoadBaseLogPartFctRef
()¶pyhrf.jde.beta.
beta_estim_obs_field
(graph, labels, gridLnz, method='MAP', weights=None)¶Estimate the amount of spatial correlation of an Ising observed field. graph is the neighbours list defining the topology labels is the field realisation gridLnz is the log-partition function associated to the topology, ie a grid where gridLnz[0] stores values of lnz and gridLnz[1] stores corresponding values of beta.
Returns: |
|
---|
pyhrf.jde.beta.
logpf_ising_onsager
(size, beta)¶Calculate log partition function in terms of beta for an Ising field of size ‘size’. ‘beta’ can be scalar or numpy.array. Assumptions: the field is 2D, squared, toroidal and has 4-connectivity