Skip to content

LinearRegression: add constructor overload that accepts IEnumerable<Coordinates> #3981

@swharden

Description

@swharden

... to make it easier to get a regression line from List<Coordinates> instead of requiring Coordinates[]

public LinearRegression(Coordinates[] coordinates)
{
if (coordinates.Length < 2)
{
throw new ArgumentException($"{nameof(coordinates)} must have at least 2 points");
}
double[] xs = coordinates.Select(x => x.X).ToArray();
double[] ys = coordinates.Select(x => x.Y).ToArray();
(Slope, Offset, Rsquared) = GetCoefficients(xs, ys);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueThis issue has limited complexity and may be a good start for new contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions