Liking likelihood

# 2004 International Union of Crystallography Printed in Denmark ± all rights reserved Maximum-likelihood methods have now been applied to most areas of macromolecular crystallography, including data reduction, molecular replacement, experimental phasing and re®nement. However, students of macromolecular crystallography are predominantly taught only traditional crystallographic methods and therefore have little understanding of the methods underlying the modern software that they routinely use in structure determination. This situation arises, at least in part, because maximum likelihood is considered to be too dif®cult to be taught to students who lack substantial mathematical training within the limited time frame of undergraduate/graduate courses. A method of introducing maximum-likelihood concepts with the help of dice is described here and it is then shown how these concepts can form the core of understanding maximum-likelihood re®nement, molecular replacement and experimental phasing. Within the framework described, the crystallographic maximum-likelihood techniques are all reduced to the same basic concepts and become easier and less time-consuming to teach than traditional methods, which rely on disparate concepts. Received 26 January 2004 Accepted 30 June 2004


Introduction
Maximum likelihood is a branch of statistical inference that asserts that the best hypothesis (i.e. set of parameters, which includes estimates of the errors) on the evidence of the data is the one that explains what has in fact been observed with the highest probability. In the context of macromolecular crystallography, maximum likelihood has come to refer to the set of new statistical methods that improved upon the leastsquares methods that preceded them. The least-squares methods were not contrary to the principle of maximum likelihood, since least squares is a special case of maximum likelihood where the errors in the parameters are simple Gaussians, rather than more complex functions. The slow acceptance of maximum likelihood was therefore not because maximum likelihood itself was considered inappropriate, but because least squares works acceptably when the data and model are good and because computers were not capable of performing the more complex calculations required for more sophisticated maximum-likelihood treatments in reasonable times. Maximum likelihood is not the only method for obtaining a set of parameters from experimental data. Indeed, in other ®elds of application maximum likelihood may not be the best method, as maximum-likelihood estimators can be severely biased. However, maximum likelihood gives little bias when applied in crystallography and it has been extremely successful in supplying better probability models, particularly when the data and/or model are poor, and has been instrumental in the solution of numerous macromolecular structures.
Dice have a long history in the explanation of problems in likelihood, maximum entropy and Bayesian theory (e.g. Jaynes, 1968Jaynes, , 1979Frieden, 1985;Mohammed-Djafari, 2003). In this tradition, I present here basic maximum-likelihood concepts using thought experiments with dice. These concepts are then used to explain maximum-likelihood re®nement, molecular replacement and experimental phasing.

Experiments with dice
There are six important concepts that are needed in order to understand the statistical approach of maximum likelihood in crystallography: maximum likelihood, independence, loglikelihood, Bayes' theorem, integrating out nuisance variables and the central limit theorem. These concepts will be explored with the help of dice with different numbers of sides ( Fig. 1).

Dice and probability
A game of dice. I put four unbiased dice in a box: one four-sided, one sixsided, one eight-sided and one ten-sided.
I select a die at random. How often will you guess correctly which die I selected?
It is obvious that there is a one in four chance of getting the correct answer. If the experiment is performed a large number of times you will guess the answer a quarter of the time, or if a large number of people guess each time a quarter will guess correctly.

Dice and maximum likelihood
A game of dice with data. I put four unbiased dice in a box: one four-sided, one sixsided, one eight-sided and one ten-sided.
I select a die at random. I roll the die and tell you the result of the roll. Which die was the most likely to be selected?
If I were to roll a 10, it is obvious that the die selected must have been the ten-sided die. Why is it obvious? Because the probability of rolling a 10 from the four-, six-or eight-sided die is zero, but the probability of rolling a 10 from the ten-sided die is non-zero. The probability is written as where the semi-colon means`given' (for a glossary of terms see Table 1) and I have denoted the type of die by its number of sides in bold. The probability of the observed data (the number rolled) given the model (the number of sides of the die) is called the likelihood.
What would be the case if I rolled a 7? If the same analysis is performed again, the likelihood of rolling a 7 from the four-or six-sided die is 0, but the likelihood of rolling a 7 from the eight-sided die is one in eight and the likelihood of rolling a 7 from the ten-sided die is one in ten. Therefore, it is most likely that the eight-sided die would have been selected. What if I roll a 1? It is most likely that the four-sided die would have been selected. The most likely die is the one with the highest likelihood of generating the data: this is the principle of maximum likelihood.
How con®dent are you that the die is an eight-sided die if the roll was a 7? Not very, because the difference between the likelihood of rolling a 7 from the eight-sided and ten-sided die is only small. The ratio between two likelihoods is a measure of con®dence (known as the likelihood ratio). For example, when I roll a 10, the likelihood ratio agrees that you are supremely con®dent that I selected a ten-sided die, rather than, say, the eight-sided die, In the case where I roll a 7, the likelihood-ratio is close to 1 (the ratio for equal likelihoods),  Photographs of (a) four-sided die, (b) six-sided die, (c) ten-sided die and (d) eight-sided die Table 1 Glossary of terms.
N i1 a i = a 1 + F F F + a N Sum of all a i for i between 1 and N N i1 a i = a 1 Â F F F Â a N Product of all a i for i between 1 and N De®nite integral of function f(x) between values a and b I 0 (x) Modi®ed Bessel function of order 0 with argument x P(A; B) Probability of A, given B P(A, B; C) Probability of A and B, given C P(A; B, C) Probability of A, given B and C F Structure factor (vector) F Structure-factor amplitude ' 2 or AE Variance of a Gaussian x G y x is proportional to y x A y x implies y

Dice, independence and log-likelihood
A game of dice with more data. I put four unbiased dice in a box: one four-sided, one sixsided, one eight-sided and one ten-sided.
I select a die at random. I roll that die three times and tell you the results of the rolls. Which die did I most likely select?
If I roll a 7 three times, you would expect that I selected an eight-sided die, as the answer should be consistent with the game above when only one roll (of a 7) was made. How is the formal analysis performed? The chance of rolling a 7 three times from the four-or six-sided die is 0, but what is the chance of throwing a 7 three times from an eight-sided or ten-sided die? The chance of throwing a 7, or any other number, the second or third time is not in¯uenced by the value of the ®rst roll. This is the principle of independence. When probabilities are independent, they multiply. If the calculations are performed, the eight-sided die is indeed more likely, 10 Â 1 10 Â 1 10 1 1000 X After obtaining data from three rolls, your con®dence that you have guessed the correct die has increased compared with when you only knew the result of one roll, so the likelihood ratio increases, What is the probability of rolling a 7 from an eight-sided die one hundred thousand times? (Of course, if you really were to roll 7 one hundred thousand times, you might have some dif®culty believing that the die is unbiased. Please continue to assume that it is.) Although the formula for the probability can be written down, P7 F F F one hundred thousand timesY 8 1 8 100 000 Y and you could work out the answer and write it down on a (very long) piece of paper, the number is too small (has too many decimal places) to be stored by a computer. The solution to this computational problem is to calculate log-likelihood rather than the likelihood, logP7 F F F one hundred thousand timesY 8 À90 309X Calculation of the log-likelihood solves the small-number computation problem, but is the switch from using the likelihood allowed? Fortunately it is, because logarithmic functions are monotonic functions [i.e. if a < b then log(a) < log(b)]. This means that the parameter values obtained by optimizing log-likelihood are the same as the parameter values obtained by optimizing the likelihood. In fact, computer algorithms are designed to minimize, so parameters are optimized by minimizing the Àlog-likelihood. There are also other more theoretical justi®cations for using the log-likelihood, which come from the statistical ®eld of information theory. Is there a paradox in that the computer needs to store the likelihood before taking its logarithm? Fortunately not, because there is a shortcut to the log-likelihood when the total likelihood is a product of likelihoods, (i.e. when the likelihoods are independent), In the case where I rolled 7 three times from an eight-sided die, there are thus two ways of calculating the log-likelihood. Using the product method,

À2X70927X
Using the sum method, However, the product method required the intermediate of calculating a number close to zero (0.001953), while the sum method did not require any numbers close to zero (the smallest numbers were the independent probabilities themselves, 0.125).
When the log-likelihood is used instead of the likelihood, the log-likelihood gain is calculated instead of the likelihood ratio. The log-likelihood gain is the difference between loglikelihoods [since log(a/b) = log(a) À log(b)]. Whereas for the likelihood ratio more favourable likelihoods are indicated by values greater than 1, for the log-likelihood gain they are indicated by any positive value. The log-likelihood gain for the die being the eight-sided rather than the ten-sided after rolling 7 three times is logP7Y 7Y 7Y 8 À logP7Y 7Y 7Y 10 À2X70927 À À3

0X29073X
What would happen if the result of previous rolls in¯uenced the result of the subsequent rolls? In this case the data points are not independent, but correlated. Note that correlation is not the same as bias. A biased die would be one that, for example, always rolled a 7, but a correlated die would be one that, for example, always rolled one number higher than the previous roll. Highly correlated data points make the determination of the likelihood dif®cult, if not impossible, and so the assumption of independence is often applied even when it is not justi®ed. In crystallography, re¯ections are assumed to be independent, even though to a certain extent they are not. Correlations are introduced by the presence of solvent, which means that the molecular transform is over-sampled, and by non-crystallographic symmetry (if present). However, the correlations are suf®ciently weak that the approximation of assuming independence is very good. To calculate the total log-likelihood for all the re¯ections in a data set (of the order of one hundred thousand), the sum of the log-likelihoods for each re¯ection is used.

Dice and Bayes' theorem
A game of dice with multiple copies of a die. I put one eight-sided die and eight ten-sided dice in a box. I select a die at random. I roll the die and tell you the result of the roll. Which die did I most likely select? I roll a 4. In this case the probability of selecting the tensided die in the ®rst place overwhelms the slightly higher chance of rolling the 4 from the eight-sided die. The chance of selecting the ten-sided die in the ®rst place is included in the probability calculation with Bayes' theorem, In experimental situations P(data) is constant and when comparing probabilities can be ignored, so Bayes' theorem becomes Pmodel; data Pmodel Â Pdata; modelX Bayes' theorem is also called the rule of inverse probability since it shows how to turn P(data; model) (e.g. the probability of rolling the 4 from the ten-sided die, which we can calculate) into P(model; data) (e.g. the probability of the ten-sided die given a roll of 4, which is what we want to know). P(model) is the probability of the model without having any data (e.g. the chance of selecting the ten-sided die in the ®rst place). P(model; data) is called the posterior probability, P(data; model) is called the likelihood (as before) and P(model) is called the prior probability. If Bayes' theorem is used to calculate the probability rather that just the likelihood, then the method of optimizing the probability should properly be called the maximum-posterior method, rather than the maximum-likelihood method, but the term`maximum likelihood' is generally used for both. True maximum likelihood can be thought of as a special case of maximum posterior when the prior probability P(model) is constant for all the models. This was the case for the examples in xx2.2 and 2.3 above. Using Bayes' theorem, the probability that the die was tensided given a roll of 4, P10Y 4 P10 Â P4Y 10 8 9 Â 1 10 0X0 " 8Y is higher than the probability that the die was eight-sided given a roll of 4, so a ten-sided die is more likely, as expected. Bayes' theorem is very useful in crystallography because it enables exploitation of the things that are known about protein structure even before the X-ray data are collected. For example, a carbon±oxygen double bond is known to be 1.23 A Ê long. So, if the electron density for a structure showed no density 1.23 A Ê from a particular peptide carbon, but a large piece of density 2 A Ê away from it, prior knowledge of the carbon±oxygen double-bond length means that it would be extremely unlikely that the density 2 A Ê away was due to an O atom bound to the carbonyl O atom. It would be more likely that the density 2 A Ê away from the carbon was due to noise or some other feature of the structure. However, if the O atom had been moved into this density during rebuilding (and the carbon±oxygen bond stretched), a re®nement program would use Bayes' theorem to restrain the bond length to 1.23 A Ê and produce the more likely structure. Bayes' theorem is also used in density modi®cation, where information about solvent content, non-crystallographic symmetry etc. is introduced (Terwilliger, 2000;McCoy, 2002).

Dice and integrating out nuisance variables
A game of dice with unknown dice. I put a six-sided and an eight-sided die in a red box and a four-sided and ten-sided die in a blue box.
I select a die from each of the red and blue boxes at random and put them in a yellow box.
I select a die at random from the yellow box, roll the die and tell you the result.
Did the die most likely come from the red box or the blue box originally? I roll a 3. The problem here is to calculate the likelihoods P(3; blue box) and P(3; red box) and ®nd the maximum without knowing which die actually produced the roll of 3. (a) One-dimensional Gaussian {1/[(2%) 1/2 ']} exp [À(x À ") 2 /2' 2 ] and (b) radially symmetric two-dimensional Gaussian [1/(2%' 2 )] exp [À(x À l| 2 )/ 2' 2 ]. The mean is " (one-dimensional)/l (two-dimensional). The standard deviation is ', which is half-width at $61% of the peak height. The variance is ' 2 . The full-width half-maximum (FWHM) = 2.35'. The area (one-dimensional)/volume (two-dimensional) under the curve is 1. Consider P(3; blue box). The blue box could have contained either the four-sided or the ten-sided die. To calculate P(3; blue box), the likelihood of the 3 being rolled from the two possibilities for the contents of the blue box (the four-sided and the ten-sided die) are added, The basic probability identity P(A, B) = P(B; A) Â P(A) [which can also have any number of conditions added, so P(A, B; C) = P(B; A, C) Â P(A; C), for example] can be used to write Substituting in values for these probabilities, P3Y blue box 1 4 Â 1 2 1 10 Â 1 2 0X175X Likewise, P(3; red box) is the likelihood of the 3 being rolled and the die being six-sided plus the likelihood of the 3 being rolled and the die being eight-sided, So, it is slightly more likely that the die came from the blue box if I roll a 3. The likelihood for the red and blue boxes has been calculated even though which die actually produced the roll of 3 was not known. Summing the probabilities for all the possibilities for the die solves the problem of not knowing which die actually produced the roll. In general, if the unknown variable (call it x) of the model can take n values between a and b, then The probability distribution for the dice is for discrete variables, because it is only de®ned for certain values (the dice must have an integer number of sides). In crystallography, the probability distributions are for continuous variables, meaning that they are de®ned for all values (an in®nite number) over an interval (for example, an atom can be anywhere and an occupancy can be anywhere between 0 and 1). When the probability distribution is continuous, the sum in the equation for the discrete probability distribution becomes an integral, because an integral can be thought of as a sum of an in®nite number of in®nitesimally small numbers. If the unknown variable x can take values between a and b, then The unknown variable x is called a nuisance variable. The removal of a nuisance variable from a probability distribution by integration is called integrate out (or marginalization of) the nuisance variable. Although termed`nuisance', these variables can be very useful in probability distributions. It may be easier to describe a probability function using an extra variable (such as the phase of the observed structure factor) and then to integrating it out at the end of the analysis than to attempt to develop a probability function without ever referring to the extra variable.

Dice and the central limit theorem
A game of dice taking the average of many rolls of the dice. I have a six-sided die. I roll the die 40 times and add up the values of the rolls, then divide the sum by 40.
I do this 10 000 times, plotting the ®nal average value from each game on a histogram.
What form does the histogram take?
The histogram is Gaussian (bell-shaped curve, see Fig. 2), with a maximum at 3.5 (see Fig. 3). Now I play the game again with a biased six-sided die: the die is biased so that it will roll its values with a probability linearly proportional to the value, i.e. a 2 is twice as likely as a 1, a 3 is three times as likely as a 1 etc. Again, the histogram looks like a Gaussian. The only difference is that the mean of the distribution is shifted to about 4.3 and the variance of the distribution is smaller (see Fig. 2 for an explanation of the mean and variance of a Gaussian). Now I play the game again with a six-sided die that is biased so that it will roll its values with a probability proportional to the square of the value i.e. a 2 is four times more likely than a 1, a 3 is nine times more likely than a 1 etc. Again, the histogram looks like a Gaussian (with an even higher mean and smaller variance). For most types of bias of the die, the histogram generated by the game of dice is Gaussian, even when the bias of the die (from which the average is computed) is decidedly non-Gaussian. This property is called the central limit theorem. The central limit theorem is possibly the most important theorem in probability. In crystallography, the central limit theorem allows us to describe the errors in the structure factors (in reciprocal space) that arise from errors in the atomic model (in real space). It says that even though the errors in an individual atom's contribution to the total structure factor may be very complicated, in the end the error for the total structure factor (the sum of the atomic structure-factor contributions) is a simple two-dimensional Gaussian in reciprocal space.

Dice summary
Maximum likelihood: the best model is the one that maximizes the probability of observing the experimental data.
Independence: probabilities multiply when the experimental data points are independent, i.e. all observations are independent of one another.
Log-likelihood: the log-likelihood is used instead of the likelihood as it has its maximum at the same parameter values research papers as the likelihood but it is safer to calculate on a computer because the numerical range is smaller.
Bayes' theorem: P(model; data) = P(model) Â P(data; model), where P(data; model) is called the likelihood and P(model) is called the prior probability.
Integrating out variables: nuisance variables in a joint probability distribution can be eliminated by integration.
Central limit theorem: the distribution of the average tends to be Gaussian, even when the distribution from which the average is computed is decidedly non-Gaussian.

Maximum likelihood in macromolecular crystallography
There are many ways of applying maximum likelihood to crystallography. Ideally, all the information from chemistry and the diffraction experiment should be included to create the`mother of all likelihood functions'. Although the chemical and diffraction information that should contribute to this likelihood function is known, there are too many correlations between the contributions to allow a practical precise formula to be written down. This is rather unfortunate, because there is enough information in the chemistry and the diffraction experiment to solve the phase problem ab initio (cf. direct methods; Bricogne, 1993). Instead, simpli®cations and approximations are made to allow maximum likelihood to be applied to speci®c areas of crystallography such as re®nement, molecular replacement and experimental phasing.

Refinement
The Bayesian view of crystallographic re®nement is that the prior probability comes from chemistry (a great deal is known about what molecules look like even before the experiment) and the likelihood comes from the X-ray diffraction experiment (Pannu & Read, 1996;Bricogne & Irwin, 1996;Murshudov et al., 1997). The probability function for re®nement (here called P-re®nement) is thus, by Bayes' theorem (see x2.4), the product of the prior probability (here called P-chemistry) and the likelihood (here called P-Xray), The chemical probabilities for all the different chemical interactions in the structure are taken to be independent (see x2.3), so that P-chemistry is the product of these individual chemical interaction probabilities P-chemistry i . This is not a very good approximation, as the bond lengths and angles are correlated with each other; the problems that this approximation causes are discussed in x4.4. If the number of interactions is I, It is also assumed that re¯ections are independent, so that P-Xray is the product of the re¯ection likelihoods (P-Xray r ). This is a good approximation (see x2.3). If the number of re¯ections is R, P-Xray R r1 P-Xray r X Since there are hundreds of thousands of interactions and hundreds of thousands of re¯ections, the log-likelihood is calculated rather than the likelihood (see x2.3). To optimize the model parameters (atomic positions, occupancies and B factors), the Àlog-likelihood is minimized, log P-Xray r X

Prior probability
Macromolecules obey the same chemical rules as small organic molecules and so ideal bond lengths and angles for macromolecules can be derived from the results of smallmolecule crystallography (Engh & Huber, 1991). The bond lengths and angles in the crystal are restrained to these ideal values using a probability distribution. For example, the prior probability for having a bond of length b is given by a Gaussian about the ideal length b ideal for the bond type (see Fig. 2 for the equation for a Gaussian), Errors for an atomic structure factor. (a) An atom has variation in position (indicated by purple arrow) and in scattering (indicated in green concentric circles). (b) The variation in the atom's position and scattering are Gaussian. (c) The atom at its mean position with its mean scattering has a structure factor F atom (shown with a black vector). Variation in the atom's position corresponds to variation in the phase of F atom (shown with a purple arrow) and variation in the scattering corresponds to variation in the length of F atom (shown with a green arrow). (d) The distributions of the structure factors owing to variation in the atom's position and scattering combine to give a boomerang-shaped structure-factor distribution (indicated with black contours). Since the distribution of structure factors is symmetric about F atom , the average structure factor is shorter than F atom (by a fraction d, where 0 < d < 1) but in the same direction as F atom (dF atom ).

Figure 4
Total structure factor for all scattering in unit cell. (a) The unit cell contains six symmetry-related molecules. (b) The total structure factor (F c ) for a re¯ection is built up by adding the structure-factor contributions from the atoms in a molecule (F atom ) to give the structure factor for the molecules (F m ) and then adding all the symmetry-related structure-factor contributions for all the molecules in the unit cell.

Figure 6
Errors in the total structure factor. (a) The unit cell contains six symmetry-related molecules. The atoms have errors in their positions and scattering, indicated by the arrows and concentric circles, respectively. (b) By the central limit, the probability distribution for the sum of the structure-factor contributions from all the atoms is a two-dimensional Gaussian in reciprocal space, centred at DF c , where 0 < D < 1, shown with grey shading. The structure-factor contributions from atoms and molecules as in Fig. 4 are shown in pink. and a ' b of about 0.02 A Ê . There are similar equations for the other types of chemical interaction restraints.

Refinement likelihood
The likelihood for a re¯ection (P-X-ray r ) is the probability of the data (i.e. the observed structure-factor amplitude F o ) given the current model. The model is in real space and the X-ray observed data are in reciprocal space, so in order to calculate the likelihood, the model (in real space) must be used to calculate structure factors (in reciprocal space). The structure factor for the whole unit cell (F c ) is calculated as follows: ®rst the structure factor for the model in the asymmetric unit (F m ) is calculated from the sum of the structure factors of the atoms in that model (F atom ). Then, F m and all its symmetry relatives are added to obtain the total structure factor F c (see Fig. 4; the importance of the symmetry relatives will become apparent in the explanation of the rotationfunction likelihood below). However, the data for a given re¯ection is the observed structure-factor amplitude F o , so in order to compare like with like the model must be the calculated structure-factor amplitude F c , Without considering errors, if F c matches F o the probability is 1 and if it does not match the probability is 0 (the model is either`correct' or`incorrect'). However, if errors in the model and the data are considered, then F c and F o are allowed to differ somewhat and the likelihood function should give a non-zero probability when F c and F o are close (the closer the better). It is easier to model the errors in terms of the phased structure factors F c and F o with the phase between them de®ned as , rather than in terms of the structure-factor amplitudes alone. The introduced variable, the phase , is a nuisance variable (a case where a nuisance variable is very useful) and must be integrated out of the probability distribution at the end of the analysis (see x2.5). The integration limits are 0±2%, i.e. all angles, The errors in the model arise from Gaussian errors in the atomic positions and atomic scattering. Gaussian errors in the atomic positions and scattering give rise to Gaussian errors in the phases and amplitudes of the corresponding atomic structure-factor contributions, respectively (see Fig. 5). When these atomic structure-factor contributions and their errors are summed to give the total structure factor and its error for a given re¯ection, by the central limit theorem (see x2.6) the resulting distribution is a two-dimensional Gaussian (see Fig. 2) in reciprocal space centred on DF c (where D is between 0 and 1) with variance termed ' 2 Á (see Fig. 6), Using this probability and the integral above, it can be shown (Appendix A) that the likelihood function is a Rice distribution (Sim, 1959;Read, 1990), where I 0 is the modi®ed Bessel function of order 0. The Rice distribution is the key distribution for maximum likelihood in crystallography and it will appear over and over again in the equations below. It applies to acentric re¯ections (those for which the phase is not restricted) and, for simplicity, the discussions below will only concern acentric structure factors (and assume the expected intensity factor, generally denoted 4, to be 1). For a full explanation of the derivation of the Rice function, see Appendix A. Centric structure factors (those where the phase is restricted to 0 or 180 ) are treated similarly to give a different likelihood function (see Appendix B).
There are also experimental errors (' F ) in the measurements. Experimental error is accounted for by widening the probability distribution, a method that is termed in¯ating the variance (Green, 1979;Murshudov et al., 1997;de La Fortelle & Bricogne, 1997). The likelihood function used for re®nement is therefore given by

Sigma A
D and ' Á are anticorrelated: if the model is very bad and therefore if ' 2 Á is large then D will be small and vice versa. If E values (normalized structure factors) are used rather than F values, D and ' Á can be replaced with a single parameter ' A (Srinivasan & Ramachandran, 1965), with DF c = ' A E c and where ' E is the normalized structure-factor experimental error. The probability distributions are very sensitive to the estimates of ' A , and ' A is re®ned along with the atomic parameters in structure re®nement. Unfortunately, if the same data are used to re®ne ' A and the atomic parameters, the data are severely over®tted and ' A is overestimated. This problem is partially avoided by estimating ' A from the data that are used to compute R free (which are excluded from the re®nement).

Weighting
In principle, if all errors are estimated properly there is no need to apply a weighting between the prior probability (P-chemistry) and likelihood (P-Xray) to calculate P-re®nement using Bayes' theorem, but in practice it is necessary to overweight the likelihood (P-Xray) for re®nement to converge. This is partly because the probabilities used are only research papers approximate (particularly for the chemistry terms, where the correlations between bond lengths and angles are not taken into account) and partly because the re®nement algorithm does not account for the fact that improvements in the model will sharpen the experimental likelihood function (because the model and the ' A values are re®ned against different subsets of the data). As the resolution becomes higher and the model becomes better, the amount of over-weighting required is reduced.

Experimental phases
Experimental phasing information can be incorporated into the re®nement likelihood function as a prior probability when integrating out the phase (Pannu et al., 1998). The prior probability can be modelled using Hendrickson±Lattman coef®cients (Hendrickson & Lattman, 1970).

Probabilities and energies
Some re®nement programs minimize energy rather than the Àlog-likelihood. In fact, the two targets of re®nement are equivalent. If the experiment is considered as a physical system with energy, Boltzmann's law gives the probability P of observing a state in the physical system with energy E, P G expÀEakTY where k is Boltzmann's constant and T is the temperature. Taking the logarithm of Boltzman's law, the energy is proportional to the logarithm of the probability, E G ÀkT ln PX Boltzman's law in logarithm form leads to harmonic bond restraints, Boltzman's law in this logarithm form also allows Bayes' theorem (in terms of probabilities) to be expressed in terms of energies

P-refinement P-chemistry Â P-Xray
A E-refinement E-chemistry E-XrayX

Molecular replacement
Maximum-likelihood molecular replacement (Bricogne, 1992;Read, 2001Read, , 2003b can be divided into a rotation function (RF) followed by a translation function (TF) in the same way that traditional molecular-replacement methods are. Each type of search is a`brute-force' search procedure. The likelihood for the models is generated on a grid of angles (RF) or positions (TF) and the angle (RF) or position (TF) of the model that has the highest likelihood is selected as the`solution' to the molecular-replacement problem. Currently, prior information (such as packing constraints and non-crystallographic symmetry) is not included in maximum-likelihood molecular replacement and so Bayes' theorem (see x2.4) is not used. Re¯ections are assumed to be independent, so that the likelihood for the rotation function (here called P-RF) and the likelihood for the translation function (here called P-TF) is the product of the re¯ection likelihoods (see x2.3). If the number of re¯ections is R, P-RF R r1 P-RF r and P-TF R r1 P-TF r X In practice, the Àlog-likelihood is used as the target for the molecular-replacement searches, log P-RF r and À log P-TF À R r1 log P-TF r X

Translation-function likelihood
The data are the observed structure-factor amplitudes (F o ) and the model is the molecular-replacement structure oriented and positioned at the search point. This is exactly the same situation as for re®nement: the approximate locations of all the atoms are known and a structure-factor amplitude F c can be calculated from the scattering in the unit cell. The translation function target is therefore the same Rice function as the target for maximum-likelihood structure re®nement. The only difference is that the errors will be much larger for the translation function than for re®nement (D will be smaller and ' Á larger). The same function is also suitable for a brute-force six-dimensional (orientation and position) search,

Rotation-function likelihood
At each rotation-function search orientation, the model consists of the molecular-replacement model with de®ned orientation but unde®ned position. Unde®ned positions in real space correspond to unde®ned phases of the structurefactor contributions in reciprocal space. Thus, F c cannot be calculated from the sum of the phased structure-factor contributions as it was for the case of re®nement and the translation function. However, because the relative positions of the atoms in the model are known, the atomic structurefactor contributions (F atom ) for the model can be added up research papers with relative phases to calculate F m , i.e. the amplitude but not the phase of the model structure-factor contribution. This can also be performed for all the symmetry relatives of the model in order to obtain the set of amplitudes of the model structurefactor contributions, {F m } sym . The symmetry relatives have different amplitudes because as the model rotates its strength of scattering in any given direction changes. Since these model structure-factor contributions are unphased, they cannot be added together to obtain the structure factor for the scattering from the whole unit cell, F c . The model in reciprocal space for the rotation function is therefore not F c , but the set of amplitudes of the model structure-factor contributions, {F m } sym , It is easiest to generate a function for this probability by introducing a (useful) nuisance phase variable, the phase between the observed structure factor F o and one of the F m . It is best to select the symmetry relative of F m with the largest amplitude, F big (the reason is given shortly). The symmetry operator that gives rise to the largest F m will be different for each re¯ection, so F big corresponds to a different symmetry operator for each re¯ection. The set of symmetry relatives of F m is thus split into the set not including F big , {F m } symT big , which are left unphased, and F big , which is given the phase relative to F o . The introduced nuisance phase must be integrated out of the probability distribution at the end of the analysis (see x2.6), The probability distribution for {F m } symT big comes from à random walk' (Fig. 7) in reciprocal space. Fixing the phase of the largest of the symmetry relatives of F m results in the narrowest probability distribution for the`random walk' and this is why the largest F m was chosen to have the phase relative to F o . Errors in the model must also be accounted for in the probability distribution, just as they were for re®nement. Using the same reasoning that applied for developing the re®nement target (see Fig. 6), errors in the model mean that all symmetry relatives of F m (including F big ) are downweighted by a D-factor (0 D 1). The probability distribution is thus a two-dimensional Gaussian centred on DF big with variance AE S dependent on {DF m } symT big (see Fig. 8), Using this probability and the integral above, it can be shown (Appendix A) that the likelihood function is another Rice distribution, Random walk. (a) Starting at the origin, a walker takes N (in this case, ®ve) steps, each step in a random direction. Each step is the same length and independent of the previous one. Because of the many random choices, the ®nal position of the walker varies each time. Four ®nal positions are shown (marked Â). Some ®nal positions are more likely than others. (b) The probability that the walker will be at a given ®nal position after N steps is proportional to a two-dimensional Gaussian, shown with grey shading.

Figure 8
Rotation-function likelihood. (a) The unit cell contains six symmetryrelated molecules. For a given orientation of the search, the orientation but not the position of the six molecules is de®ned. Therefore, the amplitudes but not the phases of the six corresponding structure-factor contributions are de®ned. The atoms in the molecules have errors in their positions and scattering, indicated by the arrows and concentric circles, respectively. The molecule in the orientation giving the largest scattering is shown in magenta. (b) The largest model structure-factor contribution, F big , is given a phase relative to the observed structure factor F o , with the other model structure-factor contributions making a`random walk' around the end of this one phased structure-factor contribution. (c) The resulting probability distribution for F o is a two-dimensional Gaussian centred on DF big , shown with grey shading.
Experimental errors (' F ) are incorporated by in¯ating the variance of the distribution, as was the case for the re®nement likelihood function, Notice the similarities between this equation and the equation for P-Xray r [and P-TF r ; (1)]. The only differences are that F big replaces F c and AE S replaces ' 2 Á . The latter difference shows an unfortunate inconsistency in the notation for variances that has arisen in crystallography. Sometimes the variance is shown as the square of the standard deviation, with the standard deviation written with a lower case Greek sigma (e.g. ' 2 Á ), and sometimes the variance is shown as a single parameter, written with an upper case Greek sigma (e.g. AE S ). The differences in the equations can be traced back to differences in the position of the centre and difference in the width of the twodimensional Gaussian in reciprocal space that gave rise to the Rice distribution.

Partial structure
Maximum-likelihood molecular replacement allows incorporation of any information about the structure already determined, e.g. known orientation and position of partial structure, known orientation of partial structure only and any combination thereof. Any partial structure information makes the probability distribution more exacting (reduces the variance) and improves the signal of the search.

Fast searches
Maximum-likelihood brute-force rotation and translation searches are very slow to compute. However, there are approximations to the full search targets that can be calculated with fast Fourier transforms and are therefore much faster. The fast rotation search is calculated with a series of twodimensional fast Fourier transforms, while the fast translation search is calculated with one three-dimensional fast Fourier transform. These likelihood-enhanced fast rotation and translation searches can be generated by a Taylor series expansion of the full likelihood targets .

Experimental phasing
There are many forms of experimental phasing, including MIR (multiple-wavelength isomorphous replacement), MIRAS (multiple-wavelength isomorphous replacement with anomalous scattering), MAD (multiple-wavelength anomalous dispersion) and SAD (single-wavelength anomalous dispersion). They all have different types of data and types of models and so require different types of likelihood functions (Bricogne, 1991;Read, 1991Read, , 1994de La Fortelle & Bricogne, 1997). Prior information is not included in maximumlikelihood experimental phasing and so Bayes' theorem is not used (see x2.4). Re¯ections are assumed to be independent, so that the total likelihood is the product of re¯ection likelihoods (see x2.3). If the number of re¯ections is R, then for example in the case of MIR the likelihood (here called P-MIR) is given by In practice, the Àlog-likelihood is used, Similarly, the MIRAS, MAD and SAD likelihoods are the products of their respective re¯ection likelihoods. The heavy-atom sites must have been found using a Patterson, direct-methods or dual-space method before invoking maximum-likelihood phasing. The heavy-atom sites (in real space) are then used to calculate the model for maximum likelihood, the heavy-atom structure factors F H (in reciprocal space).

MIR likelihood
In MIR, the data are the observed native and derivative structure-factor amplitudes. Unfortunately, there are signi®cant correlations in the data because all data sets share the scattering from the native protein component, i.e. if a re¯ection is strong/weak in the native then it is likely to be strong/ weak in all the derivative data sets as well. To simplify the analysis a (useful) nuisance variable is introduced, the`true' structure factor F T , which is the component of scattering shared by the native and derivatives (Read, 2003a) and can be thought of as the scattering from a`true' crystal. With the introduction of F T in maximum-likelihood MIR there is nothing`special' about the native data set. The native is treated in exactly the same way as the derivatives: the native is simply a derivative without heavy atoms. In the nomenclature used here, the observed native and derivative structure factors are all denoted F o . Elsewhere, F o is often written as F P , denoting that it contains native protein only, or F PH , denoting that it contains native protein and heavy atoms. The data, the set of all`native' and derivative observed structure-factor amplitudes, is denoted {F oj }, and the model, the set of all calculated heavy-atom structure factors, is denoted {F Hj }, with the derivative number denoted by the subscript j. The introduced (useful) nuisance variable F T must be integrated out of the probability distribution at the end of the analysis (see x2.6). Since F T is a vector, integrating out the parameter requires integrating over the whole complex plane (a double integral, with real and imaginary components integrated from +I to ÀI). The MIR likelihood function for a re¯ection is therefore given by P-MIR r Pdata; model PfF oj gY fF Hj g I ÀI I ÀI PfF oj gY F T Y fF Hj g dF T X 3 The reason for introducing the nuisance variable F T is that by explicitly including the correlated component of the scattering between all the data, the`leftover' parts of the scattering can be considered to be independent. Therefore, the probabilities for each derivative F oj given its F Hj and F T are (approximately) independent and can be multiplied to give the joint conditional probability (see x2.3), However, this is an expression for the probability of {F oj } given {F Hj } and F T , not for the probability of {F oj } and F T given {F Hj }, which is what is required for integrating out F T (3). The relationship between the two probabilities is given by P(B, A; C) = P(A; C) Â P(B; C, A). Taking F T A, {F oj } B and {F Hj } C, PfF oj gY F T Y fF Hj g PF T Y fF Hj g Â PfF oj gY fF Hj gY F T X If the`true crystal' lacks atoms at the heavy-atom positions of the derivative, then P(F T ; {F Hj }) is the same as P(F T ), i.e. {F Hj } is irrelevant. P(F T ) is then the probability of F T when all that is known is the number and type of atoms in the`true crystal' e.g. the number of C, N, O and S atoms if the`true crystal' contains protein only (Wilson, 1949). The probability distribution given by this information is relatively¯at and can be ignored (Read, 1991). [However, if F T does have atoms coincident with the heavy-atom positions, it should be included (Read, 2003a).] PfF oj gY F T Y fF Hj g PfF oj gY fF Hj gY F T X 5 Combining (4) and (5), Substituting (6) into the integral (3), P(F oj ; F Hj ,F T ) is the probability of the observed structurefactor amplitude F oj given F H and F T for derivative j; to calculate this probability, F Hj and F T must be used to calculate the structure-factor amplitude F cj that can be compared with F oj . The calculated structure factor (phased) F cj is the sum of the heavy-atom and protein structure factors (phased) for the derivative. If the heavy-atom model is perfect (and thus F Hj is perfect) and the protein component of the derivative is identical (isomorphous) to F T , then the calculated structure factor F cj is simply given by the sum of F Hj and F T . However, F Hj will not be perfect because the heavy atoms will not have perfect positions and occupancies and some of the sites may be missing from the model and F T will not be perfectly isomorphous with the native component of the derivative.
Using the same reasoning that applied for developing the re®nement target, F T and F Hj are thus down-weighted by D factors (0 D 1). Re®ning the D factor for F Hj has the same effect as re®ning the occupancies and B factors of the heavy atoms and so can be absorbed by these parameters during re®nement. Including errors, the calculated structure factor F cj is given by The calculated structure-factor amplitude F cj (in terms of F T and F Hj ) can now be compared with the observed structurefactor amplitude F oj , As was the case for deriving the equation for re®nement likelihood and the rotation-function likelihood, the trick to deriving a maximum-likelihood MIR function is to introduce the phase difference between the observed and calculated structure factors while developing the likelihood function and then to integrate out this (useful) nuisance phase at the end of the analysis (Bricogne, 1991;Read, 1991), The probability of F oj is a two-dimensional Gaussian in reciprocal space centred on F cj with variance ' 2 Áj (Fig. 9), Áj 2 3 X Using this probability and the integral above, it can be shown (Appendix A) that the likelihood function is yet another Rice distribution, X Experimental errors are incorporated by in¯ating the variance of the distribution This is the likelihood function for a single re¯ection and a single derivative. Notice the similarities between this equation and the equations for P-Xray r [and P-TF r ; (1)] and P-RF r (2). The likelihood function is virtually identical to that for P-Xray r except that F c is not calculated directly from the model but from the sum of DF T and F H . To combine all the research papers derivatives, the product over all the derivatives is taken before integrating out the nuisance parameter F T . Substituting (8) into (7), Unfortunately, the integrating out of F T cannot be performed analytically; it must be performed numerically (values calculated and summed). Double numerical integrations are generally slow to compute and so they have to be performed cleverly.
The MIR likelihood function assumes that errors in the models of heavy atoms are uncorrelated to one another. It also assumes that the non-isomorphism differences between the derivatives are uncorrelated to one another. This is not always the case, particularly when the heavy-atom compounds are chemically related.

MIRAS likelihood
The likelihood function for MIRAS is the probability of all the F o and F À o given all the calculated heavy-atom structure factors F H and F À H (rather than just the mean F o and mean F H as for MIR). However, this probability function is dif®cult to generate by maximum likelihood because F o and F À o are highly correlated (if F o is large/small then F À o will also be large/small). This problem is partially avoided if the mean F o and anomalous difference ÁF are used instead of F o and F À o , as these are less correlated with one another (if the mean F is large, the anomalous difference ÁF need not be large; North, 1965;Matthews, 1966;de La Fortelle & Bricogne, 1997). The probabilities for the normal and anomalous scattering components are then considered to be independent. The probability of the normal scattering component is the same as that derived for MIR. The probability for the anomalous difference is approximated by a least-squares term (rather than being given by a true likelihood term).

MAD likelihood
Currently, MAD phasing is treated as a case of MIRAS (de La Fortelle & Bricogne, 1997), where the derivatives correspond to the wavelengths. This is unsatisfactory because the assumption that the errors in the models of heavy atoms between derivatives (i.e. wavelengths) are uncorrelated with one another is necessarily violated in MAD. To be treated properly, the likelihood function would have to be computed by performing an integration for each unknown phase. For example, in two-wavelength MAD, four integrations would be required, one each for !1 , À !1 , !2 and À !2 . Only one such integral can be performed analytically (to give a Rice distribution) and all the others must be performed numerically. Numerical instability and limitations in computing power currently preclude this approach, although Bricogne (2000) has proposed an alternative solution to the problem of performing multiple integrations.

SAD likelihood
In the special case of SAD, there is a likelihood function that explicitly accounts for the correlations between F o and F À o (Pannu & Read, 2004). The function includes the familiar Rice distribution, which primarily accounts for the anomalous difference, but also another term that accounts for the heavy atoms being part of the model of the normal scatterers . Only a single numerical (phase) integration is required. The SAD likelihood for a re¯ection (P-SAD r ) is given by

Discussion
The Rice distribution is ubiquitous where maximum likelihood is applied in crystallography because it is the result of integrating out the phase of a two-dimensional Gaussian: the phase must be integrated out because only structure-factor amplitudes are measured and two-dimensional Gaussians are ubiquitous because of the central limit theorem or`random walks' of structure-factor components. In fact, the twodimensional Gaussians arising from`random walks' are also fundamentally a result of the central limit theorem. Understanding how and why the Rice distribution arises are concepts that link maximum likelihood to all aspects of macromolecular crystallography. I hope that this material will give students the con®dence to look deeper into the maximum-likelihood literature and discover some of the subtleties lost in the simple explanations. For those who are inspired to know more, the crystallography course notes at http://www-structmed.cimr.cam.ac.uk (by Randy J. Read, Airlie J. McCoy, Andrew G. W. Leslie and Philip R. Evans) are recommended as an appropriate second step.

APPENDIX A Probability distribution for acentric reflections
The probability distribution for F o given F c is a twodimensional Gaussian with variance ' 2 Á centred on F c (Fig. 10), The cosine rule with the phase between F o and F c gives research papers The likelihood function is given by integrating out the phase from the probability P(F o , ; F c ) (Fig. 10a), The relationship between P(F o , ; F c ) and P(F o ; F c ) is given by where the factor F o is introduced by changing the descriptions of the Fs from Cartesian coordinates (i.e. expressed in terms of real and imaginary components) to polar coordinates (i.e. expressed in terms of radial and angular components; this factor is called the Jacobian). Therefore, This integral has an analytical solution of the form 2% 0 expz cos d 2%I 0 zY where I 0 is the modi®ed Bessel function of order 0. Therefore, This is known as the Rice distribution (Fig. 10b). In the special case where F c is zero, This is known as the Wilson distribution.

APPENDIX B Probability distribution for centric reflections
The probability distribution for F o given F c is a onedimensional Gaussian with variance ' 2 Á centred on F c . F o is either in phase or out of phase with F c (Fig. 11). Summing over the two possibilities for the unknown phase, Expanding the quadratics and using This is known as the Woolfson distribution (Woolfson, 1956). In the special case where F c is zero, Woolfson distribution. The probability distribution for F o given F c is a one-dimensional Gaussian centred on F c . Since the re¯ection is centric, F o either has the same phase as F c or is 180 out of phase with F c .

Figure 10
Rice distribution. (a) The integral of the two-dimensional Gaussian is the sum of values on concentric circles around the origin (shown in grey). As F c increases, the two-dimensional Gaussian becomes further offset from the origin (shown with red, yellow, green, blue and purple shading). (b) A series of ®ve Rice functions are plotted in red, yellow, green, blue and purple for the different values of F c indicated with the same colour shading in (a). As F c increases, the Rice function becomes more like a one-dimensional Gaussian.