Forum > Lazarus Extra Components

Lmath ulogifit samples

**erik2727**:

Hi,

I was looking for some samples on how to use ulogifit for 4 parameters logistic curve fit,

Could someone share some tips or guide please? Below are my code snippet, not sure if the TVector B parameter result output is correct or not ?

var

X:array [0..9] of Float=(0,1,2,3,4,5,6,7,8,9,10);

Y:array [0..9] of Float=(10,11,25,36,82,90,106,201,301,403);

TX,TY:TVector;

vecB: array of Float;

B: TVector;

MatV: TMatrix;

beta,alpha:Float;

A1,B1,N:Float;

begin

TX:=X;

TY:=Y;

DimVector(TX,10);

DimVector(TY,10);

SetLength(vecB,5);

B := vecB;

DimMatrix(MatV, 0, 4);

LogiFit(TX, TY, 1, 9,true,true, 1000, 0.001, B, MatV);

A1:=B[0];

B1:=B[1];

alpha:=B[2];

beta:=B[3];

N:=B[4];

**Paolo**:

I don't know about LogiFit, but I see something wrong in your code:

1) you declare X : array [0..9], this means that you have 10 elements in the array, but you initialize 11 elements ! from 0 to 10, I think this should not compile !

2) why declare vecB : arrray of float and not as TVector !

3) by using DimMatrix(MatV, 0, 4) are you saying that the matrix has one dimension = 0 ! I think also this should not complie, it should be DimMAtrix(MatV, 5, 5) according to matrix 5x5 = [0..4,0..4]. (Maybe the martix is just an output so it is the LogiFit that domesnions it properly, I don't know.

**erik2727**:

Hi,

If you don't know lmath especially logistics mathematical functions in detail, i suggest you don't simply give your

comments, pascal blueprint are based on Fortran!

First X element should be 1 not zero, rest of the

code compile successfully, readup Lmath what is underlying principle and basis on model construction, I has compared the result with famous C++ non linear solver just like to know why this algorithm assume highest k carrying capacity is the actual high end number and deduce rest of parameters bases on fixed preset as I have no access to Original Fortran 90 solver

**Paolo**:

Hi, I admit to have replaied too hasty (in the attempt to help in someway).

Bye.

**alanphys**:

Hi

Have a look at the regexlin.pas demo in the demo/bgi/regmodel directory of LMath.

Regards

Navigation

[0] Message Index

[#] Next page