Skip to content

Linear regression fails on unevenly-spaced X data #290

@bclehmann

Description

@bclehmann

I used this set:

x,y
1,2
2,2
3,3
4,3
5,3.8
6,4.2
7,4

On my (emulated) TI-84 Plus, I got this result: https://photos.app.goo.gl/vmQ47RBT8p6tqNaG6

And on a separate statistics program (https://github.com/Benny121221/wstat) I got this printout:
image

However, using ScottPlot, I got the same offset, but the slope was 0.3200000. The proper slope is 0.4

I cannot see anything in the code that is obviously incorrect, however it is strange to me that the linreg code cares about the x-spacing, the spacing of x values doesn't matter to the LSRL.

I will make a PR to try and fix this, hopefully without causing any breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions