Linear and Exponential Regression

Prev Next

Function Names

regression

Description

Calculates the linear or exponential regression for a set of points along a given timeline and outputs them as set reflecting a linear or exponential curve.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1-2

Parameters

No.TypeDescription
1
input
set input values

Set of numerals (blank strings are allowed and recognized as zero) to be used to calculate the CAGR

Opt. 2
input
string Regression calculation method

Accepts following three values:
linear for linear regression, and
exponential for exponential regression.

Default value: linear

Return value

TypeDescription
set Regression curve

Contains as many elements as provided in the 1st function parameter and describes the linear or exponential regression curve.

Examples

               echo( regression( {1, 1.5, 2.5, 4, 6.5 } ) ); // returns { 0.4, 1.75, 3.1, 4.45, 5.8 }
               echo( regression( {1, 1.5, 2.5, 4, 6.5 }, exponential) ); // returns an exponential pattern

Output

{0.4,1.75,3.1,4.45,5.8}
{0.9714978281,1.5581934649,2.4991994875,4.0084868914,6.4292455398}
Try it yourself: Open LIB_Function_regression.b4p in B4P_Examples.zip. Decompress before use.

See also

average