# Partition Function and Equilibrium Properties

In contrast to methods that compute the property of a single structure in the ensemble, e.g. Minimum Free Energy (MFE) Algorithms, the partition function algorithms always consider the entire equilibrium ensemble. For that purpose, the algorithm(s) made available by McCaskill [1990] and its variants can be used to efficiently compute

- the partition function, and from that

- various equilibrium probabilities, for instance base pair probabilities, probabilities of individual structure motifs, and many more.

The principal idea behind this approach is that in equilibrium, statistical mechanics and polymer theory tells us that the frequency or probability \(p(s)\) of a particular state \(s\) depends on its energy \(E(s)\) and follows a Boltzmann distribution, i.e.

\[p(s) \propto e^{-\beta E(s)} \text{ with } \beta = \frac{1}{kT}\]

where \(k \approx 1.987 \cdot 10^{-3} \frac{kcal}{mol~K}\) is the Boltzmann constant, and \(T\) the thermodynamic temperature. From that relation, the actual probability of state \(s\) can then be obtained using a proper scaling factor, the canonical partition function

\[Z = \sum_{s \in \Omega} e^{-\beta E(s)}\]

where \(\Omega\) is the finite set of all states. Finally, the equilibrium probability of state \(s\) can be computed as

\[p(s) = \frac{e^{-\beta E(s)}}{Z}\]

Instead of enumerating all states exhaustively to compute \(Z\) one can apply the Secondary Structure Folding Recurrences again for an efficient computation in cubic time. An outside variant of the same recursions is then used to compute probabilities for base pairs, stretches of consecutive unpaired nucleotides, or structural motifs.

See also…

Further details of the Partition function and Base Pair Probability algorithm can be obtained from McCaskill [1990]

Specialized Modules:

- Global Partition Function and Equilibrium Probabilities
- Local (sliding window) Partition Function and Equilibrium Probabilities
- Predicting various Thermodynamic Properties
- Deprecated Interface for Global Partition Function Computation
- Deprecated Interface for Local (Sliding Window) Partition Function Computation

## Partition Function API

Similar to our Minimum Free Energy (MFE) Algorithms, we provide two different flavors for partition function computations:

- Global Partition Function and Equilibrium Probabilities - to compute the partition function for a full length sequence

- Local (sliding window) Partition Function and Equilibrium Probabilities - to compute the partition function of each window using a sliding window approach

While the global partition function approach supports predictions using single sequences as well as consensus partition functions for multiple sequence alignments (MSA), we currently do not support MSA input for the local variant.

Comparative prediction computes an average of the free energy contributions plus an additional covariance pseudo-energy term, exactly as we do for the Minimum Free Energy (MFE) Algorithms.

Boltzmann weights for the free energy contributions of individual loops can be found in Energy Evaluation for Individual Loops.

Our implementations also provide a stochastic backtracking procedure to draw @ref subopt_stochbt according to their equilibrium probabilty.

## General Partition Function API

  Functions

  int vrna_pf_float_precision(void)
    #include <ViennaRNA/part_func.h>

    Find out whether partition function computations are using single precision floating points.

    See also

    FLT_OR_DBL

    Returns:

      1 if single precision is used, 0 otherwise