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.
Glossary
Partition Function

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.
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.
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.
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.
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.
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.
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.
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.
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.
Partition Function vs. Minimum Free Energy
Comparison of the two fundamental statistical mechanical approaches for predicting RNA secondary structure from sequence
| Feature | Partition Function | Minimum 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 |
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts that interact with the partition function to define RNA structural ensembles and thermodynamic properties.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us