Dew Stats Master .NET
MulLinEval Routines
Summary
Evaluates multiple linear function.

Unit
RegModels

Declaration
Function MulLinEval(const B: array of TSample; X: TVec; Constant: boolean = false): TSample;
Result
b[0] + b[1]*x[0] + b[2]*x[1] + ... for given value X and parameters in B array.

Declaration
Procedure MulLinEval(const B: array of TSample; X: TMtx; YHat: TVec; Constant: boolean = false);

Description
Evaluates b[0] + b[1]*x[0] + b[2]*x[1] + ... for given values in X vector, parameters in B array, and returns the results in XHat vector. Size and Complex properties of XHat vector are adjusted automatically.

Use this version if you want to evaluate multiple linear function for multiple values at the same time. This is a lot faster than calling single value version for each x value.

Categories
Linearizable regression models
 See Also 
MulLinFit 

Example 1

Evaluate multiple linear function for multiple values at the same time.

Uses MathExpr, RegModels; procedure Example; var YHat: Vector; X: Matrix; begin X.SetIt(3,3,false,[2, -3, 5, 1, 6, -4, 8, 7, 9]); MulLinEval([1, 0.5, -2],X,YHat,false); // no constant term ! // YHat = (-9.5, 12, -6.5) end;
#include "MtxVecCpp.h" #include "Math387.hpp" #include "RegModels.hpp" #include "MtxVecTee.hpp" void __fastcall Example(); { Matrix X; Vector YHat; X->SetIt(3,3,false,OPENARRAY(TSample,(2, -3, 5, 1, 6, -4, 8, 7, 9))); MulLineEval(OPENARRAY(TSample,(1,0.5,-2)),X,YHat,false); // no constant term! // YHat = (-9.5, 12, -6.5) }
using Dew.Math; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Matrix X = new Matrix(0,0); Vector YHat = new Vector(0); X.SetIt(3,3,false,new double[]{2, -3, 5, 1, 6, -4, 8, 7, 9}); // Evaluate, no constant term! RegModels.MulLineEval(new double[] {1.0, 0.5, -2.0},X,YHat, false); // YHat = (-9.5, 12, -6.5) } }


Copyright 2008 Dew Research
http://www.dewresearch.com