Editing 2048: Curve-Fitting

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 8: Line 8:
  
 
==Explanation==
 
==Explanation==
 +
{{incomplete|Please edit the explanation below and only mention here why it isn't complete. Do NOT delete this tag too soon.}}
  
An illustration of several plots of the same data with {{w|Curve fitting|curves fitted}} to the points, paired with conclusions that you might draw about the person who made them. These data, when plotted on an X/Y graph, appear to have a general upward trend, but the data is far too noisy, with too few data points, to clearly suggest any specific growth pattern. In such a case, many different mathematical and statistical models ''could'' be presented as roughly fitting the data, but none of them fits well enough to compellingly represent the data.  
+
An illustration of several plots of the same data with {{w|Curve fitting|curves fitted}} to the points, paired with conclusions that you might draw about the person who made them. This data, when plotted on an X/Y graph, looks somewhat random and there is a desire or need to determine some kind of pattern. With some kinds of data the pattern can be visually obvious, and perhaps a straight or diagonal line, represented by a simple mathematical formula, hits or comes very near hitting all the points. In other cases where it's not as intuitively obvious, one begins to look for more sophisticated mathematical formulas that appear to fit the data, in order to be able to extrapolate or interpolate other data that wasn't in the initial sampling.
  
When modeling such a problem statistically, much of the work of a data scientist or statistician is knowing which fitting method is most appropriate for the data in question. Here we see various hypothetical scientists or statisticians each applying their own interpretations to the exact same data, and the comic mocks each of them for their various personal biases or other assorted excuses. In general, the researcher will specify the form of an equation for the line to be drawn, and an algorithm will produce the actual line.
+
When modeling such a problem statistically, it is common to search for trends, and fitted curves can help reveal these trends. Much of the work of a data scientist or statistician is knowing which fitting method to use for the data in question. Here we see various hypothetical scientists or statisticians each applying their own interpretations, and the comic mocks each of them for their various personal biases or other assorted excuses. In general, the researcher will specify the form of an equation for the line to be drawn, and an algorithm will produce the actual line.
  
 
Nonetheless scientists work much more seriously on the reliability of their assumptions by giving a value for the {{w|Standard deviation|standard deviation}} represented by the Greek letter sigma σ or the Latin letter s as a measure to quantify the amount of variation of the data points against the presented ''best fit''. If the σ-value isn't good enough an interpretation based on a specific fit wouldn't be accepted by the science community.
 
Nonetheless scientists work much more seriously on the reliability of their assumptions by giving a value for the {{w|Standard deviation|standard deviation}} represented by the Greek letter sigma σ or the Latin letter s as a measure to quantify the amount of variation of the data points against the presented ''best fit''. If the σ-value isn't good enough an interpretation based on a specific fit wouldn't be accepted by the science community.
Line 21: Line 22:
 
<math>f(x) = mx + b</math>
 
<math>f(x) = mx + b</math>
  
{{w|Linear regression}} is the most basic form of regression; it tries to find the straight line that best approximates the data. As it's the simplest, most widely taught form of regression, and in general differentiable functions are locally well approximated by a straight line, it's usually the first and most trivial attempt of fit.
+
{{w|Linear regression}} is the most basic form of regression; it tries to find the straight line that best approximates the data. As it's the simplest, most widely taught form of regression, and in general derivable function are locally well approximated by a straight line, it's usually the first and most trivial attempt of fit.
  
The picture to the right shows how totally different data sets can result in the same line. It's obvious that some more basics about the nature of the data must be used to understand if this simple line really does make sense.
+
The picture to the right shows how totally different data sets can result into the same line. It's obvious that some more basics about the nature of the data must be used to understand if this simple line really does make sense.
  
 
The comment below the graph ''"Hey, I did a regression."'' refers to the fact that this is just the easiest way of fitting data into a curve.
 
The comment below the graph ''"Hey, I did a regression."'' refers to the fact that this is just the easiest way of fitting data into a curve.
Line 30: Line 31:
 
<math>f(x) = ax^2 + bx + c</math>
 
<math>f(x) = ax^2 + bx + c</math>
  
{{w|Polynomial regression|Quadratic fit}} (i.e. fitting a parabola through the data) is the lowest grade polynomial that can be used to fit data through a curved line; if the data exhibits clearly "curved" behavior (or if the experimenter feels that its growth should be more than linear), a parabola is often the first, easiest, stab at fitting the data.
+
{{w|Polynomial regression|Quadratic fit}} (i.e. fitting a parabola through the data) is the lowest grade polynomial that can be used to fit data through a curved line; if the data exhibits clearly "curved" behavior (or if the experimenter feels that its growth should be more than linear), a parabola is often the first stab at fitting the data.
  
The comment below the graph ''"I wanted a curved line, so I made one with math."'' suggests that a quadratic regression is used when straight lines no longer satisfy the researcher, but they still want to use simple math expression. Quadratic correlations like this are mathematically valid and one of the simplest kind of curve in math, but this curve doesn't appear to satisfy the data any better than does simple, linear regression.
+
The comment below the graph ''"I wanted a curved line, so I made one with Math."'' suggests that a quadratic regression requires Math while the linear regression doesn't which is obviously not true.
  
 
===Logarithmic===
 
===Logarithmic===
 
[[File:Logarithm_plots.png|thumb|200px|Common logarithm functions.]]
 
[[File:Logarithm_plots.png|thumb|200px|Common logarithm functions.]]
<math>f(x) = a\log_b(x)</math>
+
<math>f(x) = a\log_b(x) + c</math>
  
A {{w|Logarithm|logarithmic}} curve grows slower on higher values, but still grows without bound to infinity rather than approaching a horizontal {{w|asymptote}}. The small ''b'' in the formula represents the base which is in most cases ''{{w|e (mathematical constant)|e}}'', 10, or 2. If the data presumably does approach a horizontal asymptote then this fit isn't an effective method to explain the nature of the data.
+
A {{w|Logarithm|logarithmic}} curve growths slower on higher values, but still grows without bound to infinity rather than approaching a horizontal asymptote. The small ''b'' in the formula represents the base which is in most cases 2, ''{{w|e (mathematical constant)|e}}'', or 10. If the data presumably does approach a horizontal asymptote then this fit isn't an effective method to explain the nature of the data.
  
 
The comment below the graph ''"Look, it's tapering off!"'' builds up the impression that the data diminishes while under this fit it's still growing to infinity, only much slower than a linear regression does.
 
The comment below the graph ''"Look, it's tapering off!"'' builds up the impression that the data diminishes while under this fit it's still growing to infinity, only much slower than a linear regression does.
Line 44: Line 45:
 
===Exponential===
 
===Exponential===
 
[[File:Exponential.svg|thumb|200px|Exponential growth (green) compared to other functions.]]
 
[[File:Exponential.svg|thumb|200px|Exponential growth (green) compared to other functions.]]
<math>f(x) = a\cdot b^x</math>
+
<math>f(x) = a\cdot b^x + c</math>
  
An {{w|Exponential growth|exponential curve}}, on the contrary, is typical of a phenomenon whose growth gets rapidly faster and faster - a common case is a process that generates stuff that contributes to the process itself; think bacteria growth or compound interest.
+
An {{w|Exponential growth|exponential curve}}, on the contrary, is typical of a phenomenon whose growth gets rapidly faster and faster - a common case is a process that generates stuff that contributes to the process itself, think bacteria growth or compound interest.
  
 
The logarithmic and exponential interpretations could very easily be fudged or engineered by a researcher with an agenda (such as by taking a misleading subset or even outright lying about the regression), which the comic mocks by juxtaposing them side-by-side on the same set of data.
 
The logarithmic and exponential interpretations could very easily be fudged or engineered by a researcher with an agenda (such as by taking a misleading subset or even outright lying about the regression), which the comic mocks by juxtaposing them side-by-side on the same set of data.
Line 53: Line 54:
  
 
===LOESS===
 
===LOESS===
A {{w|Local regression|LOESS fit}} doesn't use a single formula to fit all the data, but approximates data points locally using different polynomials for each "zone" (weighting data points differently as they get further from it) and patching them together. As it has many more degrees of freedom compared to a single polynomial, it generally "fits better" to any data set, although it is generally impossible to derive any strong, "clean" mathematical correlation from it - it is just a nice smooth line that approximates the data points well, with a good degree of rejection from outliers.
+
A {{w|Local regression|LOESS fit}} doesn't use a single formula to fit all the data, but approximates data points locally using different polynomials for each "zone" (weighting differently data points as they get further from it) and patching them together. As it has much more degrees of freedom compared to a single polynomial, it generally "fits better" to any data set, although it is generally impossible to derive any strong, "clean" mathematical correlation from it - it is just a nice smooth line that approximates well the data points, with a good degree of rejection from outliers.
  
The comment below the graph ''"I'm sophisticated, not like those bumbling polynomial people."'' emphasises this more complicated interpretation, but without a simple mathematical description it's not very helpful to find informative interpretations of the underlying data.
+
The comment below the graph ''"I'm sophisticated, not like those bumbling polynomial people."'' emphasis this more complicated interpretation but without a simple mathematical description it's not much helpful to find academic descriptions on the underlying matter.
  
 
===Linear, No Slope===
 
===Linear, No Slope===
 
<math>f(x) = c</math>
 
<math>f(x) = c</math>
 
Also known as a constant function, since the function takes on the same (constant) value ''c'' for all values of ''x''. The value of ''c'' can be determined simply by taking the average of the ''y''-values in the data.
 
  
 
Apparently, the person making this line figured out pretty early on that their data analysis was turning into a scatter plot, and wanted to escape their personal stigma of scatter plots by drawing an obviously false regression line on top of it. Alternatively, they were hoping the data would be flat, and are trying to pretend that there's no real trend to the data by drawing a horizontal trend line.
 
Apparently, the person making this line figured out pretty early on that their data analysis was turning into a scatter plot, and wanted to escape their personal stigma of scatter plots by drawing an obviously false regression line on top of it. Alternatively, they were hoping the data would be flat, and are trying to pretend that there's no real trend to the data by drawing a horizontal trend line.
  
The comment below the graph ''"I'm making a scatter plot but I don't want to."'' is probably done by a student who isn't happy with their choice of field of study.
+
The comment below the graph ''"I'm making a scatter plot but I don't want to."'' is probably done by a student who isn't happy with it's choice of field of study.
  
 
===Logistic===
 
===Logistic===
Line 72: Line 71:
 
The curve provides a smooth, S-shaped transition curve between two flat intervals (like "0" and "1").
 
The curve provides a smooth, S-shaped transition curve between two flat intervals (like "0" and "1").
  
The comment below the graph ''"I need to connect these two lines, but my first idea didn't have enough math."'' implies the experimenter just wants to find a mathematically-respectable way to link two flat lines.
+
The comment below the graph ''"I need to connect these two lines, but my first idea didn't have enough Math."'' implys the experimenter just wants to find a mathematically-respectable way to link two flat lines.
  
 
===Confidence Interval===
 
===Confidence Interval===
Line 92: Line 91:
 
A classical example in physics are the different theories to explain the black body radiation at the end of the 19th century. The {{w|Wien approximation}} was good for small wavelengths while the {{w|Rayleigh–Jeans law}} worked for the larger scales (large wavelength means low frequency and thus low energy.) But there was a gap in the middle which was filled by the {{w|Planck's law}} in 1900.
 
A classical example in physics are the different theories to explain the black body radiation at the end of the 19th century. The {{w|Wien approximation}} was good for small wavelengths while the {{w|Rayleigh–Jeans law}} worked for the larger scales (large wavelength means low frequency and thus low energy.) But there was a gap in the middle which was filled by the {{w|Planck's law}} in 1900.
  
The comment below the graph ''"I have a theory, and this is the only data I could find."'' is a bit ambiguous because there are many data points ignored. Without an explanation why only a subset of the data is used this isn't a useful interpretation at all. As a matter of fact, with the extra degrees of freedom offered by the piecewise regression, it could indicate that the researcher is trying to fit the data to confirm their theory, rather than building their theory off of the data.
+
The comment below the graph ''"I have a theory, and this is the only data I could find."'' is a bit ambiguous because there are many data points ignored. Without an explanation why only a subset of the data is used this isn't a useful interpretation at all.
  
 
===Connecting lines===
 
===Connecting lines===
 
This is often used to smooth gaps in measurements. A simple example is the weather temperature which is often measured in distinct intervals. When the intervals are high enough it's safe to assume that the  temperature didn't change that much between them and connecting the data points by lines doesn't distort the real situation in many cases.
 
This is often used to smooth gaps in measurements. A simple example is the weather temperature which is often measured in distinct intervals. When the intervals are high enough it's safe to assume that the  temperature didn't change that much between them and connecting the data points by lines doesn't distort the real situation in many cases.
  
The comment below the graph ''"I clicked 'Smooth Lines' in {{w|Microsoft Excel|Excel}}."'' refers to the well known spreadsheet application from {{w|Microsoft Office}}. Like other spreadsheet applications it has the feature to visualize data from a table into a graph by many ways. "Smooth Lines" is a setting meant for use on a {{w|line graph}}, a graph in which one axis represents time; as it simply joins up every point using bezier (or similar) curves as necessary to pass through every point (rather than finding a more sensible line that accepts some minimal but non-zero acceptible level of error in the datapoints), it is not suitable for regression.
+
The comment below the graph ''"I clicked 'Smooth Lines' in Excel."'' refers to the well known spreadsheet application from Microsoft. Like other spreadsheet applications it has the feature to visualize data from a table into a graph by many ways. The usage of the ''Smooth Lines'' feature here just sounds more like playing rather than investigating.
  
 
===Ad-Hoc Filter===
 
===Ad-Hoc Filter===
Line 105: Line 104:
  
 
===House of Cards===
 
===House of Cards===
Not a real method, but a common consequence of misapplication of statistical methods: a curve can be generated that fits the data extremely well, but immediately becomes absurd as soon as one glances outside the training data sample range, and your analysis comes crashing down "like a house of cards". This is a type of ''overfitting''. In other words, the model may do quite well for (approximately) {{w|Interpolation|interpolating}} between values in the sample range, but not extend at all well to {{w|Extrapolation|extrapolating}} values outside that range.
+
Not a real method, but a common consequence of mis-application of statistical methods: a curve can be generated that fits the data extremely well, but immediately becomes absurd as soon as one glances outside the training data sample range, and your analysis comes crashing down "like a house of cards". This is a type of ''overfitting''. In other words, the model may do quite well for (approximately) {{w|Interpolation|interpolating}} between values in the sample range, but not extend at all well to {{w|Extrapolation|extrapolating}} values outside that range.
  
''Note:'' Exact polynomial fitting, a fit which gives the unique <math>(n-1)</math>th degree polynomial through <math>n</math> points, often display this kind of behaviour.
+
''Note:'' Exact polynomial fitting, a fit which gives the unique (n-1)-th degree polynomial through n points, often display this kind of behaviour.
  
 
The comment below the graph ''"As you can see, this model smoothly fits the- wait no no don't extend it AAAAAA!!"'' refers to a curve which fits the data points relatively well within the graph's boundaries, but beyond those bounds fails to match at all.
 
The comment below the graph ''"As you can see, this model smoothly fits the- wait no no don't extend it AAAAAA!!"'' refers to a curve which fits the data points relatively well within the graph's boundaries, but beyond those bounds fails to match at all.
 +
 +
Also a potential reference to the TV show, House of Cards ("WAIT NO, NO, DON'T EXTEND IT!").
  
 
===Cauchy-Lorentz (title text)===
 
===Cauchy-Lorentz (title text)===
Line 116: Line 117:
 
Since so many different models can fit this data set at first glance, Randall may be making a point about how if a data set is sufficiently messy, you can read any trend you want into it, and the trend that is chosen may say more about the researcher than about the data. This is a similar sentiment to [[1725: Linear Regression]], which also pokes fun at dubious trend lines on scatterplots.
 
Since so many different models can fit this data set at first glance, Randall may be making a point about how if a data set is sufficiently messy, you can read any trend you want into it, and the trend that is chosen may say more about the researcher than about the data. This is a similar sentiment to [[1725: Linear Regression]], which also pokes fun at dubious trend lines on scatterplots.
  
A brief Google search reveals that Augustin-Louis Cauchy originally worked as a junior engineer in a managerial position. Upon his acceptance to the Académie des Sciences in March 1816, many of his peers expressed outrage. Despite his early work in "mere" engineering, Cauchy is widely regarded as one of the founding influences in the rigorous study of calculus & accompanying proofs.  Notably, his later work included theoretical physics, and Lorentz was also a well-known physicist.  Therefore, the title-text may be referring back to [[793: Physicists]].
+
A brief Google search reveals that Augustin-Louis Cauchy originally worked as a junior engineer in a managerial position. Upon his acceptance to the Académie des Sciences in March 1816, many of his peers expressed outrage. Despite his early work in "mere" engineering, Cauchy is widely regarded as one of the founding influences in the rigorous study of calculus & accompanying proofs.
 
 
Alternately, the title-text could be implying that the person who applied the Cauchy-Lorentz curve-fitting method may not be well qualified to the task assigned.
 
  
 
==Transcript==
 
==Transcript==
Line 132: Line 131:
 
:[The second plot shows a curve falling slightly down and then rising up to the right.]
 
:[The second plot shows a curve falling slightly down and then rising up to the right.]
 
:Quadratic
 
:Quadratic
:"I wanted a curved line, so I made one with math."
+
:"I wanted a curved line, so I made one with Math."
  
 
:[At the third plot the curve starts near the left bottom and increases more and more less to the right.]
 
:[At the third plot the curve starts near the left bottom and increases more and more less to the right.]
Line 179: Line 178:
 
*This comic is similar to [[977: Map Projections]] which also uses a scientific method not commonly thought about by the general public to determine specific characteristics of one's personality and approach to science.
 
*This comic is similar to [[977: Map Projections]] which also uses a scientific method not commonly thought about by the general public to determine specific characteristics of one's personality and approach to science.
  
*Regressions have been the subject of several previous comics. [[1725: Linear Regression]] was about linear regressions on uncorrelated or poorly correlated data. [[1007: Sustainable]], [[1204: Detail]] and [[1281: Minifigs]] depict linear regressions on data that was actually logistic, leading to bizarre extrapolations. [[605: Extrapolating]] shows a line extrapolating from just two data points.
+
*Regressions have been the subject of several previous comics. [[1725: Linear Regression]] was about linear regressions on uncorrelated or poorly correlated data. [[1007: Sustainable]] and [[1204: Detail]] depict linear regressions on data that was actually logistic, leading to bizarre extrapolations. [[605: Extrapolating]] shows a line extrapolating from just two data points.
  
 
{{comic discussion}}
 
{{comic discussion}}
Line 185: Line 184:
 
[[Category:Comics with color]]
 
[[Category:Comics with color]]
 
[[Category:Scatter plots]]
 
[[Category:Scatter plots]]
[[Category:Line graphs]]
 
 
[[Category:Math]]
 
[[Category:Math]]
 
[[Category:Science]]
 
[[Category:Science]]

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)