Re: BUG #13619: regression functions return Null

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Biswadeep Banerjee <biswadeep(dot)banerjee(at)actifio(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13619: regression functions return Null
Date: 2015-09-14 19:03:06
Message-ID: CAKFQuwbA=QyL440tDGyL9TrxaCA362+xJTzJ54KFPzfhfZr5uQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

Oh, and don't reply to people individually. I'm going to move this to
-general with one last copy for -bugs even though it is not one.

On Mon, Sep 14, 2015 at 3:01 PM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Mon, Sep 14, 2015 at 2:55 PM, Biswadeep Banerjee <
> biswadeep(dot)banerjee(at)actifio(dot)com> wrote:
>
>> Hi David,
>> May be I gave a wrong example to explain my issue.
>>
>> Below is a sample query that I have been trying to get the slope and
>> intercept. The inner query basically gives me the time vs capacity, ie. x
>> and y data showing the actuals. Based on the x, y value, I calculate slope
>> and intercept value, as in the outer query.
>>
>> But it looks like am back to your comment as it mentions I am asking for
>> slope and intercept of a single point. Could you provide me some examples
>> that I can use as a reference.
>> As a reference, I am following similar example as in
>> http://stackoverflow.com/questions/20490756/linear-regression-with-postgres
>>
>> select x, y, regr_slope(y,x), regr_intercept(y,x)
>> from (
>> ​/* doesn't matter */
>>
>> ) i
>> group by x, y
>> order by x asc, y asc
>>
>
> ​You are grouping on (x, y)​
>
> ​ and then passing this single POINT into a function that requires
> multiple points in order to calculate the slope and intercept of a LINE
> (i.e., something requiring two points to describe) and are confused why it
> is giving you NULL...
>
> ​I have answered your question - you are using the functions incorrectly.
>
> This is operator error, not a bug.
>
> You have already found a reasonably good example of how these functions
> can be used. Given I have never used them myself I do not have anything
> better to offer.
>
> David J.
> ​
> ​
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Sandeep Thakkar 2015-09-15 06:13:26 Re: Installation error
Previous Message David G. Johnston 2015-09-14 16:53:08 Re: BUG #13619: regression functions return Null

Browse pgsql-general by date

  From Date Subject
Next Message Martín Marqués 2015-09-14 20:32:09 Re: BDR problem
Previous Message David G. Johnston 2015-09-14 16:59:31 Re: issue, dumping and restoring tables with table inheritance can alter column order