econiac.core.ensemble
econiac.core.ensemble
Statistical ensemble — Maslov-Gibbs partition function and routing weights.
The central object is the Gibbs distribution over a finite set of candidates with utility scores U_i and inverse temperature β:
Z(β) = Σ_i exp(β · U_i) partition function
w_i(β) = exp(β · U_i) / Z(β) routing weights (sum to 1)
F(β) = -β⁻¹ ln Z(β) free energy
Limits
β → 0 uniform weights (maximum entropy, pure exploration) β → ∞ argmax weights (tropical limit, pure exploitation)
The routing weights are the unique probability measure that minimises free energy F(β) for given β, and simultaneously preserves conformal, symplectic, and adiabatic invariance (Paper 201, Theorem 3.1).
References
Buckley (2026) MGE. doi:10.5281/zenodo.17981393 Buckley (2026) TIR. doi:10.5281/zenodo.20237288 Smith (2015) Information equilibrium. arXiv:1510.02435
EnsembleSummary
Bases: NamedTuple
Summary statistics of a Gibbs ensemble at a given β.
Source code in src/econiac/core/ensemble.py
partition_function(utilities, beta)
Z(β) = Σ exp(β · U_i), computed in log-space for numerical stability.
log_partition(utilities, beta)
gibbs_weights(utilities, beta)
Gibbs routing weights w_i(β) = exp(β·U_i) / Z(β).
Uses softmax for numerical stability. At β=0 returns uniform weights. At β→∞ concentrates on the argmax.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utilities
|
Array
|
shape (n,) array of utility scores U_i |
required |
beta
|
float
|
inverse temperature β ≥ 0 |
required |
Returns:
| Name | Type | Description |
|---|---|---|
weights |
Array
|
shape (n,) array summing to 1 |
Source code in src/econiac/core/ensemble.py
free_energy(utilities, beta)
TIR free energy F(β) = -β⁻¹ ln Z(β).
At β=0, F = -ln(n) (maximum entropy baseline). As β→∞, F → -max(U_i) (ground state energy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utilities
|
Array
|
shape (n,) array of utility scores |
required |
beta
|
float
|
inverse temperature β > 0 |
required |
Returns:
| Type | Description |
|---|---|
Array
|
scalar free energy |
Source code in src/econiac/core/ensemble.py
entropy(utilities, beta)
Shannon entropy of the Gibbs distribution H = -Σ w_i ln w_i.
Equals ln(n) at β=0, approaches 0 as β→∞.
Source code in src/econiac/core/ensemble.py
mean_utility(utilities, beta)
⟨U⟩ = Σ w_i U_i — the thermodynamic internal energy.
choose(beta, candidates, utilities)
MGE-weighted combination: returns Σ w_i(β) · candidates_i.
For scalar candidates this is the Gibbs-weighted average. For vector candidates (e.g. policy vectors, portfolio weights) this is the Gibbs mixture — a convex combination of the candidate vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
beta
|
float
|
inverse temperature β ≥ 0 |
required |
candidates
|
Array
|
shape (n,) or (n, d) — the objects to mix |
required |
utilities
|
Array
|
shape (n,) — utility score for each candidate |
required |
Returns:
| Type | Description |
|---|---|
Array
|
shape () or (d,) — the Gibbs-weighted mixture |
Source code in src/econiac/core/ensemble.py
beta_schedule(beta_0, beta_final, n_steps, kind='geometric')
Generate a β-schedule from β_0 (exploration) to β_final (exploitation).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
beta_0
|
float
|
starting inverse temperature (low, e.g. 0.1) |
required |
beta_final
|
float
|
final inverse temperature (high, e.g. 100.0) |
required |
n_steps
|
int
|
number of steps |
required |
kind
|
str
|
'linear' | 'geometric' | 'cosine' geometric is preferred — equal ratio steps preserve adiabatic invariance better than equal additive steps. |
'geometric'
|
Returns:
| Type | Description |
|---|---|
Array
|
shape (n_steps,) array of β values |
Source code in src/econiac/core/ensemble.py
ensemble_sweep(utilities, schedule)
Compute Gibbs weights at every β in a schedule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
utilities
|
Array
|
shape (n,) |
required |
schedule
|
Array
|
shape (T,) β values |
required |
Returns:
| Name | Type | Description |
|---|---|---|
weights |
Array
|
shape (T, n) — weights[t] = gibbs_weights(utilities, schedule[t]) |
Source code in src/econiac/core/ensemble.py
summarise(utilities, beta)
Compute all summary statistics for a Gibbs ensemble at β.