change in polyfit()'s behaviour?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

change in polyfit()'s behaviour?

Thomas Weber-8
Hi,

the following raises in error in the 3.0 branch:
       
        polyfit ([1,2; 3,4], [1,2; 3,4],4)
namely
error: polyfit: x and y must be vectors of the same size

In fact, this error is part of test_poly.m in the test/ subdirectory.


In the development sources, the test has been removed and the output is
now:

octave:1> polyfit ([1,2; 3,4], [1,2; 3,4],4)
ans =

   0.011358  -0.113585   0.397547   0.432076   0.272603

Is this change intentional, ie should polyfit handle matrices as input
arguments?

        Thomas
Reply | Threaded
Open this post in threaded view
|

Re: change in polyfit()'s behaviour?

bpabbott
Administrator

On Jan 3, 2009, at 11:47 AM, Thomas Weber wrote:

> Hi,
>
> the following raises in error in the 3.0 branch:
>
> polyfit ([1,2; 3,4], [1,2; 3,4],4)
> namely
> error: polyfit: x and y must be vectors of the same size
>
> In fact, this error is part of test_poly.m in the test/ subdirectory.
>
>
> In the development sources, the test has been removed and the output  
> is
> now:
>
> octave:1> polyfit ([1,2; 3,4], [1,2; 3,4],4)
> ans =
>
>   0.011358  -0.113585   0.397547   0.432076   0.272603
>
> Is this change intentional, ie should polyfit handle matrices as input
> arguments?
>
> Thomas

It is compatible behavior, so it should accept matrices, provided they  
are the same size.

 >>  polyfit ([1,2; 3,4], [1,2; 3,4],4)
Warning: Polynomial is not unique; degree >= number of data points.
 > In polyfit at 72

ans = [0.02   -0.2    0.7      0   0.48]

It *may* be sensible to add the warning regarding the equations  
exceeding the unknowns. However, QR calculates the minimum-norm which  
I understand is unique. So I'm inclined to leave it as it is.

Ben




Reply | Threaded
Open this post in threaded view
|

Re: change in polyfit()'s behaviour?

Thomas Weber-8
On Sat, Jan 03, 2009 at 01:04:52PM -0500, Ben Abbott wrote:

>
> On Jan 3, 2009, at 11:47 AM, Thomas Weber wrote:
>
>> Hi,
>>
>> the following raises in error in the 3.0 branch:
>>
>> polyfit ([1,2; 3,4], [1,2; 3,4],4)
>> namely
>> error: polyfit: x and y must be vectors of the same size
>>
>> In fact, this error is part of test_poly.m in the test/ subdirectory.
>>
>>
>> In the development sources, the test has been removed and the output  
>> is
>> now:
>>
>> octave:1> polyfit ([1,2; 3,4], [1,2; 3,4],4)
>> ans =
>>
>>   0.011358  -0.113585   0.397547   0.432076   0.272603
>>
>> Is this change intentional, ie should polyfit handle matrices as input
>> arguments?
>>
>> Thomas
>
> It is compatible behavior, so it should accept matrices, provided they  
> are the same size.

Ah, okay. I wonder whether this behaviour is intentional, though.

> It *may* be sensible to add the warning regarding the equations  
> exceeding the unknowns. However, QR calculates the minimum-norm which I
> understand is unique. So I'm inclined to leave it as it is.

Fine with me, thanks for the explanation.

        Thomas
Reply | Threaded
Open this post in threaded view
|

Re: change in polyfit()'s behaviour?

bpabbott
Administrator

On Jan 3, 2009, at 1:28 PM, Thomas Weber wrote:

> On Sat, Jan 03, 2009 at 01:04:52PM -0500, Ben Abbott wrote:
>>
>> On Jan 3, 2009, at 11:47 AM, Thomas Weber wrote:
>>
>>> Hi,
>>>
>>> the following raises in error in the 3.0 branch:
>>>
>>> polyfit ([1,2; 3,4], [1,2; 3,4],4)
>>> namely
>>> error: polyfit: x and y must be vectors of the same size
>>>
>>> In fact, this error is part of test_poly.m in the test/  
>>> subdirectory.
>>>
>>>
>>> In the development sources, the test has been removed and the output
>>> is
>>> now:
>>>
>>> octave:1> polyfit ([1,2; 3,4], [1,2; 3,4],4)
>>> ans =
>>>
>>>  0.011358  -0.113585   0.397547   0.432076   0.272603
>>>
>>> Is this change intentional, ie should polyfit handle matrices as  
>>> input
>>> arguments?
>>>
>>> Thomas
>>
>> It is compatible behavior, so it should accept matrices, provided  
>> they
>> are the same size.
>
> Ah, okay. I wonder whether this behaviour is intentional, though.

My memory is that it was intentional on our part (or at least mine).

The discussion the this changeset is below. Ironically, you led it  
off ;-)

        http://www.nabble.com/Polyfit-with-scaling-tt15191415.html#a15281777

I haven't located any discussion regarding the present topic. However,  
Dimitri did suggest wpolyfit be used as a starting point. It is  
possible that this feature was inherited from there.

Ben

Reply | Threaded
Open this post in threaded view
|

Re: change in polyfit()'s behaviour?

Thomas Weber-8
On Sat, Jan 03, 2009 at 01:51:32PM -0500, Ben Abbott wrote:

>
> On Jan 3, 2009, at 1:28 PM, Thomas Weber wrote:
>
>> On Sat, Jan 03, 2009 at 01:04:52PM -0500, Ben Abbott wrote:
>>>
>>> On Jan 3, 2009, at 11:47 AM, Thomas Weber wrote:
>>>
>>>> Hi,
>>>>
>>>> the following raises in error in the 3.0 branch:
>>>>
>>>> polyfit ([1,2; 3,4], [1,2; 3,4],4)
>>>> namely
>>>> error: polyfit: x and y must be vectors of the same size
>>>>
>>>> In fact, this error is part of test_poly.m in the test/  
>>>> subdirectory.
>>>>
>>>>
>>>> In the development sources, the test has been removed and the output
>>>> is
>>>> now:
>>>>
>>>> octave:1> polyfit ([1,2; 3,4], [1,2; 3,4],4)
>>>> ans =
>>>>
>>>>  0.011358  -0.113585   0.397547   0.432076   0.272603
>>>>
>>>> Is this change intentional, ie should polyfit handle matrices as  
>>>> input
>>>> arguments?
>>>>
>>>> Thomas
>>>
>>> It is compatible behavior, so it should accept matrices, provided  
>>> they
>>> are the same size.
>>
>> Ah, okay. I wonder whether this behaviour is intentional, though.
>
> My memory is that it was intentional on our part (or at least mine).

I was being unclear. I wonder if this behaviour is intentional on
Matlab's part. Their documentation only mentions vectors and the error
messages (for different sizes) talks about vectors of the same size.

> The discussion the this changeset is below. Ironically, you led it off
> ;-)

Yes, but I was only the messenger there.

        Thomas
Reply | Threaded
Open this post in threaded view
|

Re: change in polyfit()'s behaviour?

bpabbott
Administrator

On Jan 4, 2009, at 6:19 AM, Thomas Weber wrote:

> I was being unclear. I wonder if this behaviour is intentional on
> Matlab's part. Their documentation only mentions vectors and the error
> messages (for different sizes) talks about vectors of the same size.


ok, I misunderstood.

Beyond what you mention, I can't find anything that implies Mathworks  
did or did not intend polyfit to work this way.

Ben


Reply | Threaded
Open this post in threaded view
|

Re: change in polyfit()'s behaviour?

John W. Eaton
Administrator
On  4-Jan-2009, Ben Abbott wrote:

|
| On Jan 4, 2009, at 6:19 AM, Thomas Weber wrote:
|
| > I was being unclear. I wonder if this behaviour is intentional on
| > Matlab's part. Their documentation only mentions vectors and the error
| > messages (for different sizes) talks about vectors of the same size.
|
|
| ok, I misunderstood.
|
| Beyond what you mention, I can't find anything that implies Mathworks  
| did or did not intend polyfit to work this way.

Yeah, if you want to know whether something in Matlab is intentional,
why are you asking here?  Maybe you should ask the MathWorks?

jwe