# Errors and residuals in statistics Main Article Discussion Related Articles  [?] Bibliography  [?] External Links  [?] Citable Version  [?] This editable Main Article is under development and subject to a disclaimer. [edit intro]
The content on this page originated on Wikipedia and is yet to be significantly improved. Contributors are invited to replace and add material to make this an original article.

In statistics and optimization, the concepts of error and residual are easily confused with each other.

Error is a misnomer; an error is the amount by which an observation differs from its expected value; the latter being based on the whole population from which the statistical unit was chosen randomly. The expected value, being the average of the entire population, is typically unobservable. If the average height in a population of 21-year-old men is 5 feet 9 inches, and one randomly chosen man is 5 feet 11 inches tall, then the "error" is 2 inches; if the randomly chosen man is 5 feet 7 inches tall, then the "error" is −2 inches. The nomenclature arose from random measurement errors in astronomy. It is as if the measurement of the man's height were an attempt to measure the population average, so that any difference between the man's height and the average would be a measurement error.

A residual, on the other hand, is an observable estimate of the unobservable error. The simplest case involves a random sample of n men whose heights are measured. The sample average is used as an estimate of the population average. Then we have:

• The difference between the height of each man in the sample and the unobservable population average is an error, and
• The difference between the height of each man in the sample and the observable sample average is a residual.
Residuals are observable; errors are not.

Note that the sum of the residuals within a random sample is necessarily zero, and thus the residuals are necessarily not independent. The sum of the errors need not be zero; the errors are independent random variables if the individuals are chosen from the population independently.

Errors are often independent of each other; residuals are not independent of each other (at least in the simple situation described above, and in many others).

## An example, with some of the mathematical theory

If we assume a normally distributed population with mean μ and standard deviation σ, and choose individuals independently, then we have

$X_{1},\dots ,X_{n}\sim N(\mu ,\sigma ^{2})\,$ and the sample mean

${\overline {X}}={X_{1}+\cdots +X_{n} \over n}$ is a random variable distributed thus:

${\overline {X}}\sim N(\mu ,\sigma ^{2}/n).$ The errors are then

$\varepsilon _{i}=X_{i}-\mu ,\,$ whereas the residuals are

${\widehat {\varepsilon }}_{i}=X_{i}-{\overline {X}}.$ (As is often done, the "hat" over the letter ε indicates an observable estimate of an unobservable quantity called ε.)

The sum of squares of the errors, divided by σ2, has a chi-square distribution with n degrees of freedom:

$\sum _{i=1}^{n}\left(X_{i}-\mu \right)^{2}/\sigma ^{2}\sim \chi _{n}^{2}.$ This quantity, however, is not observable. The sum of squares of the residuals, on the other hand, is observable. The quotient of that sum by σ2 has a chi-square distribution with only n − 1 degrees of freedom:

$\sum _{i=1}^{n}\left(\,X_{i}-{\overline {X}}\,\right)^{2}/\sigma ^{2}\sim \chi _{n-1}^{2}.$ It is remarkable that the sum of squares of the residuals and the sample mean can be shown to be independent of each other. That fact and the normal and chi-square distributions given above form the basis of confidence interval calculations relying on Student's t-distribution. In those calculations one encounters the quotient

${{\overline {X}}_{n}-\mu \over S_{n}/{\sqrt {n}}},$ in which the σ appears in both the numerator and the denominator and cancels. That is fortunate because in practice one would not know the value of σ2.
{"ft_lang_label":"__label__en","ft_lang_prob":0.924512,"math_prob":0.99107206,"size":3479,"snap":"2022-40-2023-06","text_gpt3_token_len":711,"char_repetition_ratio":0.14330935,"word_repetition_ratio":0.06335616,"special_character_ratio":0.20005749,"punctuation_ratio":0.095826894,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9989723,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],"im_url_duplicate_count":[null,null,null,null,null,8,null,null,null,2,null,2,null,2,null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-09-30T19:12:32Z\",\"WARC-Record-ID\":\"<urn:uuid:1058ff42-0ed9-4ed0-9a89-3fc2e00df542>\",\"Content-Length\":\"49161\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:c37a3019-96fe-4fd1-a870-dc32ba8f9612>\",\"WARC-Concurrent-To\":\"<urn:uuid:66d16489-61db-438b-a4c8-be76fdf701cb>\",\"WARC-IP-Address\":\"208.100.31.41\",\"WARC-Target-URI\":\"https://citizendium.org/wiki/Errors_and_residuals_in_statistics\",\"WARC-Payload-Digest\":\"sha1:EY5REYELPZW66BDZVPRBJSWSRAKZB24J\",\"WARC-Block-Digest\":\"sha1:H3N3ZJJ6U42SJL6HPPNHT5FU2BEWVPYJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-40/CC-MAIN-2022-40_segments_1664030335504.22_warc_CC-MAIN-20220930181143-20220930211143-00491.warc.gz\"}"}