Answervetor results

TeeChart for ActiveX, COM and ASP
Post Reply
JKO
Newbie
Newbie
Posts: 16
Joined: Mon Mar 26, 2012 12:00 am

Answervetor results

Post by JKO » Thu Jul 12, 2012 7:01 am

Hi,

After struggling some time I got the answervector working.

Now the results the answervector presents puzzle me. Below a screenshot of the used data. On the left are the x, y-values of the raw data, on the right are the x,y-vaules of the linear (PolyDegree=2) fit.
TC1.JPG
TC1.JPG (51.64 KiB) Viewed 35640 times
The fit is performed via this code:

Code: Select all

	otemp:setfunction(tfCurveFit)
	otemp:FunctionType:asCurveFit:TypeFitting:=cfPolynomial
	otemp:FunctionType:asCurveFit:PolyDegree:=SELF:n_fitorder
	otemp:DataSource:=SELF:oDCTC:Series(wie)
	otemp:CheckDataSource()
The fit looks good and plausible on graphics.
When retrieving the corresponding answervector the following two numbers are presented:
answervector[1]=0.272339
answervector[2]=0.079659

Putting the same (raw) data in MS-Excel and fitting a linear trendline through it, the following line is produced; y=0.079659x+11.172680.
So, the calculated slope (0.079659) looks OK (assuming answervector[2] represents the slope with a linear fit).
The offset which TC calculates however looks way off (0.272339 vs. 11.172680).

Could you please explain what is going on.

TIA,

Jack

JKO
Newbie
Newbie
Posts: 16
Joined: Mon Mar 26, 2012 12:00 am

Re: Answervetor results

Post by JKO » Thu Jul 12, 2012 7:16 am

To eleborate on the above.
When fitting a 2nd order polynome (polydegree=3) through the raw data, the answervector produces this:
answervector[1]=0.435702
answervector[2]=0.018398
answervector[3]=0.003604

MS-Excel calculates on the same data y=0.003604x^2 + 0.011191x + 11.400907

So again, the highest order looks OK, but the lower orders deviate (significantly).
As said above, the grahics looks fine.

Greetings,

Jack

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Answervetor results

Post by Yeray » Thu Jul 12, 2012 1:45 pm

Hi Jack,

This was discussed here:
viewtopic.php?f=3&t=5812&start=0
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JKO
Newbie
Newbie
Posts: 16
Joined: Mon Mar 26, 2012 12:00 am

Re: Answervetor results

Post by JKO » Thu Jul 12, 2012 5:28 pm

OK, Thanks.

BUT, wouldn't it be better if you documented this unexpected behaviour OR BETTER
if you put the neccessary corrections into the code.



Greetings,

Jack

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Answervetor results

Post by Yeray » Fri Jul 13, 2012 8:23 am

Hi Jack,
JKO wrote:BUT, wouldn't it be better if you documented this unexpected behaviour OR BETTER
if you put the neccessary corrections into the code.
I agree it should be better explained and maybe offer the possibility to convert the normalized coefficients internally (as I understand it it's not exactly a correction since the values aren't incorrect, just normalized). I've added it to the wish list (TV52016255).

I've also seen there's no Curve Fitting demo in ActiveX as in VCL and .NET versions, where it's at least commented in the memo:
Finding coefficients example wrote:The Curve Fitting function returns the polynomial coefficients
in the AnswerVector property. This is an array of size from 1 to PolyDegree.
Note: X and Y values are first "normalized" ( X - MinX, Y - MinY ).
Move the mouse to find the Y value for a given X position.
I've also added to the wish list the possibility to add this demo on the ActiveX features demo (TA05016254).
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JKO
Newbie
Newbie
Posts: 16
Joined: Mon Mar 26, 2012 12:00 am

Re: Answervetor results

Post by JKO » Fri Jul 13, 2012 3:17 pm

Hi Yeray,

Good that you are taking action. Putting this in the manual is a step forward.
However, I would be a strong advocate to not rank this item as a wish (but as a bug or a flaw) for the following reason. Altough you wil document this behaviour the results of the answervector are still unexpected. You have to do extra calculations to get workable results. In case of a small order fit (like first or second) the extra calculations are more or less doable but will explode rapidly for higher orders (imagine a tenth order fit). For the normal programmer these would be impossible to solve.
Furthermore, the code to support the corrections has to be written tailormade because each fit-order has its own specific correction.

So, in short, it would be advisable (or almost mandatory) for the answervector to produce workable result and not something that has to be specifically corrected.


Greetings,

Jack

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Answervetor results

Post by Yeray » Tue Jul 17, 2012 4:01 pm

Hi Jack,

Actually, wish or bug/defect lists are internally the same list. What changes is the category of the issue but most important for us is the priority/severity we give to each issue and this is quite an important one.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JKO
Newbie
Newbie
Posts: 16
Joined: Mon Mar 26, 2012 12:00 am

Re: Answervetor results

Post by JKO » Wed Jul 18, 2012 4:48 pm

Hi Yeray,

I always tought that items on a wishlist were nice to have but are no showstoppers, have low priority, are something for a new versionnumber.
A bug/flaw is something which has to be adressed direct/soon/within a certain time periode and have certainly a higher priority than a wish.

Time frame and priority are two key factors in these kind of lists.
Sometimes you give a number to these issues (like TV52016112) and in this case not.

In short, how and where can a customor see:
1. if he reported a issue or Steema accepted the issue
2. how the issue is handled/categorised (high/low priority, is a wish, a bug, or something else)
3. within which time frame can he expect the issue be solved

To get to the point, when will this issue be solved and when will my other issue regarding the legend ("I've added it to the wish list to be investigated for future releases (TV52016112).") be solved?


Greetings,

Jack

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Answervetor results

Post by Yeray » Fri Jul 20, 2012 8:16 am

Hi Jack,
JKO wrote:I always tought that items on a wishlist were nice to have but are no showstoppers, have low priority, are something for a new versionnumber.
A bug/flaw is something which has to be adressed direct/soon/within a certain time periode and have certainly a higher priority than a wish.
Well, the bug tracking system we use here at Steema allows you to label a ticket as a "Bug", a "Feature Request" or an "Enhancement". Done the difficulty to reach a consensus on the definition of these categories and, more than this, to reach a consensus on the interpretation if some issues fit more in a definition than the next, we prefer not to discriminate between these categories. So we prefer to pay more attention to the "Severity" level assigned to the items.
JKO wrote:Time frame and priority are two key factors in these kind of lists.
We understand some of you have important problems that demand immediate intervention, but without any doubt, you'll understand we also have to value other aspects such as the number of customers affected, if there is a workaround or not, the percentage of the component that is affected, the relation cost/benefit of the implementation,...
JKO wrote:Sometimes you give a number to these issues (like TV52016112) and in this case not.
In what case not? I'm not sure to find what I've missed.
JKO wrote:In short, how and where can a customor see:
1. if he reported a issue or Steema accepted the issue
2. how the issue is handled/categorised (high/low priority, is a wish, a bug, or something else)
3. within which time frame can he expect the issue be solved
1. We use to say something like "I've added it to the * list". And we sometimes give the ticket assigned so the customers can look for the item in the release notes to see if a release includes the demanded fix/feature.
2. The technician evaluates questions like the mentioned above (number of customers affected, if there is a workaround or not, the percentage of the component that is affected, the relation cost/benefit of the implementation,...) to decide the item Severity. Of course nothing is definitive and we are happy to revise it when demanded.
3. We don't use to tell exact dates for fixes. It depends on the factors above and also on the difficulty of the solution implementation. And also, we can't omit the possibility of unpredicted complications when trying to implement a solution.
JKO wrote:To get to the point, when will this issue be solved and when will my other issue regarding the legend ("I've added it to the wish list to be investigated for future releases (TV52016112).") be solved?
I've revised the items TV52016255, TA05016254 and TV52016112. The two first items already have a quite high severity. I've incremented it for the last too.
Don't hesitate to let us know if there's any other issue you are interested on knowing its status.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

IFF
Newbie
Newbie
Posts: 1
Joined: Thu Nov 07, 2013 12:00 am

Re: Answervetor results

Post by IFF » Thu Nov 09, 2023 5:59 am

Code: Select all

//here a function to get a[n] coefficients ( Delphi ) 

//function arguments

//Xmin ->form2.ch1.series[0].XValues.MinValue
//Ymin -> form2.ch1.series[0].Yvalues.MinValue
// Xi      ->  input of x to get Yvalue  
//  Yvalue = An*xi^n + ... a1*xi + a0 
// result -> math expression 'y=An*xi^n + ... a1*xi + a0' 

Function GetPolyEquation(xmin,ymin,xi:double;var yvalue:double):string;
var k1,k0:array of integer;
      a,b:array of Extended;
      i,j,n:byte;
      tmp:string;

begin

    // (y-ymin)=b[n]*(xi-xmin)^n + ... b[0] --> Y=a[n]*xi^n + a[n-1]*xi^(n-1] +... a[0]

    with form2.TeeFunction1 do
    begin
          n:=polydegree-1;
          setlength(k1,n+2);   // to calc.  Newton Binomial coefficients
          setlength(k0,n+2);   // to calc   Newton Binomial coefficients
          setlength(a,n+2);    // (a) coefficients vector
          setlength(b,n+2);    // (b) coefficients original vector (answervector )
          //  -- initial values ---
          k0[0]:=1;
          k0[1]:=1;
          k1[0]:=1;
         for i:=0 to n do
          begin
             b[i]:=answervector[i+1];
         end;
         // initial values to n=1 ( polydegree=2)
         a[1]:=b[1];
         a[0]:=b[1]*(-xmin)+b[0]+ymin;
         // coefficients 'a'
         if n>1 then
         begin
            for j:= 2 to n do
            begin
              a[0]:=b[j]*power(-xmin,j)+a[0];
              for i:=1 to J do
              begin
                 k1[i]:=k0[i-1]+k0[i];          // Newton Binomial coefficients
                 a[i]:=k1[i]*b[j]*power(-xmin,j-i)+a[i];
               end;
               for i:=0 to j do k0[i]:=k1[i];
            end;
          end;

          // --  expression ---

          for i:=n downto 0 do
          begin
              tmp:=tmp+' ';
              if a[i]>=0 then tmp:=tmp+'+';
              tmp:=tmp+FormatFloat('0.0###E-00',a[i]);
              if i>0 then tmp:=tmp+'x';
              if i>1 then tmp:=tmp+'^'+IntToStr(i);
           end;
           result:='y= '+tmp;

           //---- Yvalue = f(xi)

           yvalue:=0;
          for i:=0 to n do
             yvalue:=a[i]*power(xi,i)+yvalue;
    end;
end;

Post Reply