Skip to content

Linear regression functions aren't implemented correctly #7064

@lukaseder

Description

@lukaseder

Many of our integration tests seem to fail when we upgrade our own emulation of linear regression functions to Firebird 4.0.0's native support.

Try this, for example:

select regr_avgx(a, b)
from (
  select 1, 1 from RDB$DATABASE union all
  select 2, 1 from RDB$DATABASE union all
  select 3, 2 from RDB$DATABASE union all
  select 4, 2 from RDB$DATABASE
) t (a, b);

Firebird 4.0 produces the value 4, when it should produce 1.5 like these database products:

Maybe, this gives you a hint about the bug?

select regr_avgx(a, b), regr_avgx(cast(a as bigint), cast(b as bigint))
from (
  select 1, 1 from RDB$DATABASE union all
  select 2, 1 from RDB$DATABASE union all
  select 3, 2 from RDB$DATABASE union all
  select 4, 2 from RDB$DATABASE
) t (a, b);

select regr_avgx(cast(a as bigint), cast(b as bigint)), regr_avgx(a, b)
from (
  select 1, 1 from RDB$DATABASE union all
  select 2, 1 from RDB$DATABASE union all
  select 3, 2 from RDB$DATABASE union all
  select 4, 2 from RDB$DATABASE
) t (a, b);

In both cases, I'm getting this, now:

|REGR_AVGX|REGR_AVGX|
|---------|---------|
|4.0      |0        |

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions