Dew Stats Master .NET
LineEval Routines
Summary
Evaluates linear function.

Unit
RegModels

Declaration
Function LineEval(const B: array of TSample; X: TSample): TSample;
Result
b[0] + b[1]*X for given value X and parameters in B array.

Example 1

Evaluate linear function for single x.

Uses RegModels, Math387; procedure Example; var y: TSample; begin y := LineEval([1,3], 2.5); // Res = 1+ 3*2.5 = 8.5 end;
#include "Math387.hpp" #include "RegModels.hpp" void __fastcall Example(); { double y = LineEval(OPENARRAY(TSample,(1.0, 3.0)),2.5); }
using Dew.Stats.Units; namespace Dew.Examples { private void Example() { RegModels.PowerEval(new double[] {1.0, 3.0}, 2.5); } }



Declaration
Procedure LineEval(const B: array of TSample; X, YHat: TVec);

Description
Evaluates b[0] + b[1]*X 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 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 
LineDeriv 
LineFit 

Example 1

Evaluate linear function for multiple values at the same time.

Uses MathExpr, MtxVecTee, Series, RegModels; procedure Example(Series1: TLineSeries); var Y,X: Vector; begin X.Size(100); X.Ramp(-5.0, 0.05); // x= -5.0, -4.95, ... -0.05 // Y = b[0] + b[1]*X LineEval([1,3],X,Y); DrawValues(X,Y,Series1,false); end;
#include "Math387.hpp" #include "RegModels.hpp" #include "MathExpr.hpp" #include "MtxVecTee.hpp" void __fastcall Example(TLineSeries* series); { Vector X,Y; X->Size(100,false); X->Ramp(-5.0, 0.1); // x= -5.0, -4.9, ..., +4.9 LineEval(OPENARRAY(TSample,(1.0, 3.0)),X,Y); DrawValues(X,Y,series,false); }
using Dew.Math; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector X = new Vector(100,false); Vector Y = new Vector(0); X.Ramp(-5.0, 0.1); RegModels.LineEval(new double[] {1.0, 3.0}, X, Y); } }



Declaration
Procedure LineEval(B, X, YHat: TVec);

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