Dew Stats Master .NET
PowerEval Routines
Summary
Evaluates power function.

Unit
RegModels

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


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

Example 1

Evaluate power function for single x.

Uses RegModels, Math387; procedure Example; var y: TSample; begin y := PowerEval([-5,3.5], 2.0); // y = -5.0*(2.0)^(3.5) = -56.568542495 end;
#include "Math387.hpp" #include "RegModels.hpp" void __fastcall Example(); { double y = PowerEval(OPENARRAY(TSample,(-5,3.5)),2.0); }
using Dew.Math; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { y = RegModels.PowerEval(new double[] {-5,3.5},2.0); } }



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

Description
Evaluates b[0]*X^b[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 power 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 
PowerDeriv 
PowerFit 

Example 1

Evaluate power 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.1); // x= -5.0, -4.9, ..., +4.9 // Y = b[0] + b[1]*X PowerEval([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 PowerEval(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.PowerEval(new double[] {1.0, 3.0}, X, Y); } }


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