Saltar al contenido principal
LibreTexts Español

9: Aproximación de mínimos cuadrados

  • Page ID
    117209
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    El método de mínimos cuadrados se usa comúnmente para ajustar una curva parametrizada a datos experimentales. En general, no se espera que la curva de ajuste pase por los puntos de datos, haciendo que este problema sea sustancialmente diferente al de la interpolación.

    Consideramos aquí solo la situación más común: el ajuste de una línea recta a través de datos con el mismo error experimental para todos los puntos de datos. Suponemos que los datos que se van a ajustar están dados por\(\left(x_{i}, y_{i}\right)\), con\(i=1\) a\(n\).

    Escribimos para la curva de ajuste

    \[y(x)=\alpha x+\beta . \nonumber \]

    La distancia\(r_{i}\) desde el punto de datos\(\left(x_{i}, y_{i}\right)\) y la curva de ajuste viene dada por

    \[\begin{aligned} r_{i} &=y_{i}-y\left(x_{i}\right) \\ &=y_{i}-\left(\alpha x_{i}+\beta\right) . \end{aligned} \nonumber \]

    Un ajuste de mínimos cuadrados minimiza la suma de los cuadrados de los\(r_{i}\) s. Este mínimo se puede mostrar para dar como resultado los valores más probables de\(\alpha\) y\(\beta\).

    Definimos

    \[\begin{aligned} \rho &=\sum_{i=1}^{n} r_{i}^{2} \\ &=\sum_{i=1}^{n}\left(y_{i}-\left(\alpha x_{i}+\beta\right)\right)^{2} \end{aligned} \nonumber \]

    Para minimizar\(\rho\) con respecto a\(\alpha\) y\(\beta\), resolvemos

    \[\frac{\partial \rho}{\partial \alpha}=0, \quad \frac{\partial \rho}{\partial \beta}=0 \nonumber \]

    Tomando las derivadas parciales, tenemos

    \[\begin{aligned} &\frac{\partial \rho}{\partial \alpha}=\sum_{i=1}^{n} 2\left(-x_{i}\right)\left(y_{i}-\left(\alpha x_{i}+\beta\right)\right)=0 \\ &\frac{\partial \rho}{\partial \beta}=\sum_{i=1}^{n} 2(-1)\left(y_{i}-\left(\alpha x_{i}+\beta\right)\right)=0 \end{aligned} \nonumber \]

    Estas ecuaciones forman un sistema de dos ecuaciones lineales en las dos incógnitas\(\alpha\) y\(\beta\), lo cual es evidente cuando se reescribe en la forma

    \[\begin{aligned} \alpha \sum_{i=1}^{n} x_{i}^{2}+\beta \sum_{i=1}^{n} x_{i} &=\sum_{i=1}^{n} x_{i} y_{i} \\ \alpha \sum_{i=1}^{n} x_{i}+\beta n &=\sum_{i=1}^{n} y_{i} \end{aligned} \nonumber \]

    Estas ecuaciones se pueden resolver numéricamente, y proporciona una subrutina incorporada llamada polyfit.m. Con los datos en los vectores\(x\) y\(y\), la llamada MATLAB

    \[\mathrm{p}=\text { polyfit }(\mathrm{x}, \mathrm{y}, 1) \text {; } \nonumber \]

    devuelve los valores\(p(1)=\alpha\) y\(p(2)=\beta\), que luego se pueden utilizar para dibujar la línea de ajuste.


    This page titled 9: Aproximación de mínimos cuadrados is shared under a CC BY 3.0 license and was authored, remixed, and/or curated by Jeffrey R. Chasnov via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.