Escolar Documentos
Profissional Documentos
Cultura Documentos
Mnimos cuadrados - 1
Anlisis de regresin
REGRESION LINEAL. y = A + B.x
y B x
n
DATOS: T,C
LONGITUD, mm
Respuesta :
n x y x y
n x 2 x
10
1003
15
1005
n x y x y
n x
20
1010
n y
25
1011
30
1014
Regresin Logartmica
(Ln x)
(Ln x)2
(Ln x).y
29
50
74 103 118
1.6 23.5 38.0 46.4 48.9
Regresin Exponencial
(Ln y)
(Ln y)2
x.(Ln y)
12,9 19,8 26,7 35,1
15,7 12,1 8,5 5,2
Regresin de Potencia
(Ln x)
(Ln x)2
(Ln y)
(Ln y)2
(Ln x.Ln y)
30
3033
33
3895
35
4491
38
5717
Mnimos cuadrados - 2
#include<iostream.h>
#include<stdlib.h>
int main()
{
float x,y,a,b,r,sx=0,sy=0,sxy=0,sx2=0,sy2=0;
int i,n;
cout << "Regresion Lineal\nIngreso de Datos x,y\n";
cout << "# de Pares de Datos : ";
cin >> n;
// Lectura de los valores x,y
for(i=1;i<=n;i++)
{
cout << "x(" << i << ") = ";
cin >> x;
cout << "y(" << i << ") = ";
cin >> y;
sx = sx + x;
sy = sy + y;
sxy = sxy + x*y;
sx2 = sx2 + x*x;
sy2 = sy2 + y*y;
}
// Calculo de las Constantes
b = (n*sxy - sx*sy)/(n*sx2 - sx*sx);
a = (sy - b*sx)/n;
r = (n*sxy - sx*sy)/sqrt((n*sx2-sx*sx)*(n*sy2-sy*sy));
cout << "\nTermino de la Constante de Regresion A : " << a << endl
<< "Coeficiente de Regresion B : " << b
<< "\nCoeficiente de Correlacion r : " << r
<< "\nEc. de la Recta : y = " << a << " + " << b << "*x";
system("PAUSE");
return 0;
}