"Algebras/Pfunc/alg_pfunc.gap" computes the partition function value for a candidate. Choice function is sum, to add up all individual partition function values. Let x be the free energy of a structure, R the universal gas constant, T the temperature in Kelvin then the partition function value is exp(-x/R*T). One could say, partition function is just a scaling of free energy. The function mk_pf() does this scaling. To avoid overflows the partition function values are scaled by the number of bases in the input sequence, i.e. the number of bases in a substructure; function scale(). The energy values themselves are identical to the MFE algebras, but they are multiplied instead of summed. The probability of a structure is its partition function value divided by the sum of the partition function values of all structures in the search space.

Since algebra functions are commonly used by other algebras (Algebras/Pfunc/alg_pknot_pfunc.gap and Algebras/Pfunc/alg_outside_pfunc.gap), they are outsourced in the file Algebras/Pfunc/algpart_pfunc_basic.gap.