Inferensys

Glossary

Partition Function

A statistical mechanics calculation that sums the Boltzmann-weighted free energies of all possible RNA secondary structures to derive base pairing probabilities and ensemble properties.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
STATISTICAL THERMODYNAMICS

What is Partition Function?

The partition function is a statistical mechanics calculation that sums the Boltzmann-weighted free energies of all possible RNA secondary structures to derive base pairing probabilities and ensemble properties.

The partition function (denoted Q) is a fundamental calculation in RNA thermodynamics that enumerates all possible secondary structures from a given sequence, weighting each by its Boltzmann factor e^(-ΔG/RT). Unlike minimum free energy (MFE) prediction, which returns a single optimal structure, the partition function captures the full thermodynamic ensemble, enabling the calculation of base pairing probabilities for every possible nucleotide pair.

Computed efficiently using a dynamic programming algorithm that extends the Turner energy model, the partition function serves as the statistical foundation for deriving ensemble-averaged properties such as Shannon entropy of the structural ensemble, melting temperature predictions, and the probability of specific motifs. It is the core calculation underlying tools like RNAfold -p and enables rigorous thermodynamic comparisons between sequences.

ENSEMBLE THERMODYNAMICS

Key Properties of the Partition Function

The partition function transforms a single minimum free energy prediction into a probabilistic ensemble view of the RNA folding landscape, enabling the calculation of base pairing probabilities, ensemble diversity, and thermodynamic parameters.

01

Boltzmann-Weighted Summation

The partition function Q is defined as the sum over all possible secondary structures s of the Boltzmann factor exp(−ΔG(s)/RT). This statistical mechanical formalism assigns a thermodynamic weight to every structure in the ensemble, ensuring that low-energy conformations dominate the sum while higher-energy states contribute exponentially less. The calculation is performed efficiently using dynamic programming algorithms that recursively compute partial sums over substructures, avoiding explicit enumeration of the astronomically large structure space.

O(n³)
Computational Complexity
exp(−ΔG/RT)
Boltzmann Factor
02

Base Pairing Probability Matrix

From the partition function, the probability P(i,j) that nucleotides i and j form a base pair is calculated as the sum of Boltzmann weights of all structures containing that pair, divided by Q. This yields a symmetric probability matrix where each entry represents the thermodynamic likelihood of a specific base pair. The matrix is typically visualized as a dot plot, with the upper triangle showing pairing probabilities and the lower triangle showing the MFE structure for comparison.

0 to 1
Probability Range
n×n
Matrix Dimensions
03

Ensemble Diversity and Shannon Entropy

The partition function enables calculation of the ensemble Shannon entropy S = −Σ P(s) log P(s), which quantifies the structural diversity of the folding landscape. A low entropy indicates a well-defined, stable fold dominated by a single structure, while high entropy reveals a conformationally dynamic RNA that samples many alternative structures. This metric is critical for identifying riboswitches and other regulatory RNAs that function through structural switching.

S = −Σ P log P
Shannon Entropy
bits
Unit of Diversity
04

Ensemble Free Energy and Thermodynamic Consistency

The ensemble free energy G° = −RT ln Q accounts for the entropic contribution of all accessible structures, making it a more accurate thermodynamic descriptor than the MFE alone. The difference between the MFE and ensemble free energy, termed the ensemble defect, measures how much the structural ensemble deviates from a single target conformation. This quantity is used in RNA design algorithms to optimize sequences that fold uniquely.

G° = −RT ln Q
Ensemble Free Energy
kcal/mol
Energy Units
05

McCaskill Algorithm

The McCaskill algorithm (1990) is the foundational dynamic programming method for computing the RNA partition function. It extends the Zuker-Stiegler MFE algorithm by replacing minimization with summation and energy values with Boltzmann factors. The algorithm recursively calculates partition functions for interior loops, hairpin loops, bulge loops, and multi-branch loops using the Turner energy parameters, enabling exact calculation of base pairing probabilities in polynomial time.

1990
Year Published
O(n³)
Time Complexity
06

Centroid Structure and Maximum Expected Accuracy

The partition function enables derivation of the centroid structure—the secondary structure that minimizes the expected base-pair distance to all structures in the ensemble. This is computed using the maximum expected accuracy (MEA) principle, where base pairs are selected to maximize the sum of pairing probabilities minus a penalty for false positives. The centroid often provides a more representative single-structure prediction than the MFE, especially for RNAs with high ensemble diversity.

γ
MEA Trade-off Parameter
Σ P(i,j) − γ
Scoring Function
THERMODYNAMIC ENSEMBLE METHODS

Partition Function vs. Minimum Free Energy

Comparison of the two fundamental statistical mechanical approaches for predicting RNA secondary structure from sequence

FeaturePartition FunctionMinimum Free Energy

Definition

Sums Boltzmann-weighted free energies of all possible secondary structures to calculate ensemble properties

Identifies the single structure with the lowest total free energy using dynamic programming

Output

Base pairing probability matrix and ensemble diversity metrics

Single optimal secondary structure in dot-bracket notation

Algorithmic Basis

McCaskill algorithm (dynamic programming over all suboptimal structures)

Zuker algorithm (dynamic programming with energy minimization traceback)

Thermodynamic Assumption

System exists as a Boltzmann ensemble of interconverting structures at equilibrium

System collapses to a single ground-state conformation

Base Pair Representation

Continuous probabilities (0.0 to 1.0) for every possible pair

Binary determination (paired or unpaired) for each nucleotide

Well-Definedness

Unique mathematical result for a given energy model

May yield multiple degenerate structures with identical minimum energy

Information Content

Captures full thermodynamic landscape including suboptimal structures

Discards all suboptimal structural information

Sensitivity to Energy Parameters

Probabilities reflect relative stability differences across the ensemble

Single parameter perturbation can switch the predicted MFE structure discontinuously

Use in Deep Learning

Probabilities serve as soft training targets and input features for neural networks

Discrete structure used as hard classification target for sequence-to-structure models

Chemical Probing Integration

Probabilities directly comparable to SHAPE reactivity profiles via pseudo-energy constraints

Requires conversion of reactivity data to hard constraints that may over-constrain prediction

Computational Complexity

O(N³) time and O(N²) memory for sequence length N

O(N³) time and O(N²) memory for sequence length N

Ensemble Defect Calculation

Enables calculation of ensemble defect (expected number of incorrectly paired nucleotides)

No ensemble-level quality metric available

Representative Implementations

RNAfold -p (ViennaRNA), RNAstructure Partition, CONTRAfold

RNAfold (ViennaRNA), mfold, RNAstructure Fold, UNAFold

RNA THERMODYNAMICS

Frequently Asked Questions

Clear answers to common questions about the partition function and its role in RNA structure prediction.

The partition function is a statistical mechanics calculation that sums the Boltzmann-weighted free energies of all possible RNA secondary structures for a given sequence. Rather than predicting a single minimum free energy (MFE) structure, the partition function enumerates the entire thermodynamic ensemble, assigning each structure a probability proportional to exp(-ΔG/RT), where ΔG is the free energy, R is the gas constant, and T is the absolute temperature. This ensemble approach, pioneered by McCaskill's algorithm in 1990, enables the calculation of base pairing probabilities—the likelihood that any two nucleotides form a pair across all possible structures—and the ensemble diversity, which quantifies how disordered the structural landscape is. The partition function is foundational for understanding RNA molecules that populate multiple functional conformations, such as riboswitches and viral regulatory elements.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.