 Find Code: All Words Any of the Words Exact Phrase Home   :   Code   :   Forums   :   Submit   :   Mailing List   :   About   :   Contact
 Code All VB.NET ASP.NET C# VB Classic ASP Classic Snippets Popular Resources Submit Code Forums Articles Tips Links Books Contest Link to us Calculate Regressions for Least Squares Method Author: Adolfo Leon Sepulveda Website: http://www.geocities.com/adoleon2000 Submitted: 2/15/2005 Version: VB.NET 2003 Compatibility: VB.NET 2002, VB.NET 2003 Category: Mathematics Downloads: 8146 'This program calculate Regressions for Least Squares Method Use 5 buttons for calculate: Power regression y= aX^b Exponential regression y=ae^(bx) Polynomial regression Ao +A1x + A2x^2... Get Y by interpolation Get X by interpolation Use 1 Multiline TextBox for results Data input from file RegPowerData.txt, ReaExpData.txt and RegPolyData.txt from folder .\bin of project RegPowerData.txt: 6.9, 21.4 12.9, 15.7 19.8, 12.1 26.7, 8.5 35.1, 5.2 fit y=30.497587426 exp(-0.049203708x) ReaExpData.txt: 28,2410 30,3033 33,3895 35,4491 38,5717 fit: y=0.238801069 x^2.771866158 RegPolyData.txt: 20,54 30,90 40,138 50,206 60,292 70,396 fit to poly order 2: y= 41.771428571 - 1.095714286x + 0.087857143x^2 For each regression exist a Class inherits from "Regression" Class: PowerRegression, ExpRegression,PolyRegression ************** Regression Class (base class for calculate Least Squares Regressions) properties: xVex, yVec: input, output data points x, y NumData: number of points aMat: store coefficients of matrix for build "normal equations" bVec: store constants of matrix for build "normal equations" also store coefficients of regression when Regr()is executed methods: Regr() : Overridable method for calculate regression BuildMat() : build "normal equations" ****************** PowerRegression Class (inherits from Regression Class) y= aX^b Calculate Power regression Methods: Regr(): Set each data point to natural logarithm and calculate regression EvaluateX() for get Y given X EvaluateY() for get X given Y **************** ExpRegression Class (inherits from Regression Class) y = a e^(bx) Calculate Exponential regression Methods: Regr(): Set each data point y(i) to Natural Logarithm and calculate regression EvaluateX() for get Y given X EvaluateY() for get X given Y **************** PolyRegression Class (inherits from Regression Class) y = Ao +A1x + A2x^2... Calculate polynomial regression Properties: DegreePoly: input dregree of polynomial ChiSquare: get Chi Square Getr2: get Coefficient of Determination StandardError: get Standard Error Methods: Regr() Lfit(): get polynomial coefficients fit EvaluateX() for get Y given X EvaluateY() for get X given Y Also this program use next Classes: ******************* GaussJordan Class solve equations systems. In This case is used for solve normal equations properties: aMat: input coefficients of equations and return inverse matrix when execute gaussj() method bVec: input constants of equations and return solution when execute gaussj() method Numeq: input number of equations Methods: gaussj(): solve equations systems ******************* Bairstow Class Find reals and complex roots of polynomials for Bairstow's Method used for interpolation: get Y value, given X in polynomial regression Properties: Degree: input degree of polynomial Poly: input polynomial Roots: store roots NumRoot: get number of roots of polynomial Tolerance: precision of calculates Iterations: Number of iterations Methods: brstow() : find real and complex roots of polynomial 