dwave.system.temperatures.maximum_pseudolikelihood_temperature#
- maximum_pseudolikelihood_temperature(bqm: BinaryQuadraticModel | None = None, sampleset: None | SampleSet | Tuple[ndarray, List] = None, en1: ndarray | None = None, num_bootstrap_samples: int = 0, seed: int | None = None, T_guess: float | None = None, optimize_method: str | None = None, T_bracket: Tuple[float, float] = (0.001, 1000), sample_weights: ndarray | None = None) Tuple[float, ndarray] [source]#
Return a sampling-based temperature estimate.
The temperature T parameterizes the Boltzmann distribution as \(P(x) = \exp(-H(x)/T)/Z(T)\), where \(P(x)\) is a probability over a state space, \(H(x)\) is the energy function (BQM) and \(Z(T)\) the partition function (a normalization constant). Given a sample set (\(S\)), a temperature estimate establishes the temperature that is most likely to have produced the sample set. An effective temperature can be derived from a sample set by considering the rate of excitations only. A maximum-pseudo-likelihood (MPL) estimator considers local excitations only, which are sufficient to establish a temperature efficiently (in compute time and number of samples). If the BQM consists of uncoupled variables then the estimator is equivalent to a maximum likelihood estimator.
The effective MPL temperature is defined by the solution T to
\[0 = \sum_i \sum_{s \in S} f_i(s) \exp(f_i(s)/T),\]where \(f\) is the energy lost in flipping spin \(i\) against its current assignment (the effective field).
The problem is a convex root-solving problem, and is solved with SciPy’s
scipy.optimize
. In the case that all samples define local minima or maxima (all energiesen1
are same sign) SciPy is bypassed and the maximizing value (T=0) is returned. This limit might be realized in low-temperature samplesets.If the distribution is not Boltzmann with respect to the BQM provided, as may be the case for heuristic samplers (such as annealers), the temperature estimate can be interpreted as characterizing only a rate of local excitations. In the case of sample sets obtained from D-Wave annealing quantum computers, the temperature can be identified with a physical temperature via a late-anneal freeze-out phenomena.
- Parameters:
bqm (
BinaryQuadraticModel
, optional) – Binary quadratic model describing sample distribution. Ifsampleset
anden1
are not provided, then by default 100 samples are drawn usingDWaveSampler
.sampleset (
SampleSet
orsamples_like
as described in theas_samples()
function, optional) – A set of samples, assumed to be fairly sampled from a Boltzmann distribution characterized bybqm
.en1 (
numpy.ndarray
object, optional) – Effective fields as annumpy.ndarray
object (site labels not required). If not provided, derived from thebqm
andsampleset
parameters. First dimension indexes samples and second dimension indexes sites. Ordering does not matter but should be consistent with thesample_weights
parameter.num_bootstrap_samples (int, optional, default=0) – Number of bootstrap estimators to calculate. Currently supported for samplesets only with uniform
sample_weights
. An aggregated or weighted sampleset must be disaggregated with repetitions.seed (int, optional) – Seeds the bootstrap method (if provided), allowing reproducibility of the estimators.
T_guess (float, optional) – User approximation to the effective temperature. Must be a positive (non-zero) scalar value. Seeding the root-search method can enable faster convergence. By default,
T_guess
is ignored if it falls outside the range ofT_bracket
.optimize_method (str, optional, default=None) – Optimize method used by the SciPy
root_scalar
algorithm. The default method (type of solver) works well under default operation; the ‘bisect’ method can be numerically more stable for the scalar case (temperature estimation only).T_bracket (list or tuple of 2 floats, optional, default=(0.001,1000)) – Relevant only if
optimize_method='bisect'
. If excitations are absent, temperature is defined as zero; otherwise this defines the range of temperatures over which to attempt a fit.sample_weights (
numpy.ndarray
, optional) – A set of weights for the samples. If sampleset is of typeSampleSet
, this defaults tosampleset.record.num_occurrences
; otherwise uniform weighting is the default.
- Returns:
The optimal parameters and a list of bootstrapped estimators (
T_estimate
,T_bootstrap_estimates
):T_estimate
: Temperature estimateT_bootstrap_estimates
: List of bootstrap estimates
- Return type:
Tuple
Examples
This example drawa samples from a D-Wave quantum computer for a large spin-glass problem (random couplers \(J\), zero external field \(h\)) and establishes a temperature estimate by maximum pseudo-likelihood.
Note that due to the complicated freeze-out properties of hard models (such as large scale spin-glasses), deviation from a classical Boltzmann distribution is anticipated. Nevertheless, the
T_estimate
can always be interpreted as an estimator of local-excitations rates. For example T will be 0 if only local minima are returned (even if some of the local minima are not ground states).>>> import dimod >>> from dwave.system.temperatures import maximum_pseudolikelihood_temperature >>> from dwave.system import DWaveSampler >>> from random import random ... >>> sampler = DWaveSampler() >>> bqm = dimod.BinaryQuadraticModel.from_ising({}, {e : 1-2*random() for e in sampler.edgelist}) >>> sampleset = sampler.sample(bqm, num_reads=100, auto_scale=False) >>> T,T_bootstrap = maximum_pseudolikelihood_temperature(bqm, sampleset) >>> print('Effective temperature ',T) Effective temperature 0.24066488780293813
See also
[Chat2007] and [Ray2016].