|
|
@ -3,7 +3,7 @@ |
|
|
// http://numerics.mathdotnet.com
|
|
|
// http://numerics.mathdotnet.com
|
|
|
// http://github.com/mathnet/mathnet-numerics
|
|
|
// http://github.com/mathnet/mathnet-numerics
|
|
|
//
|
|
|
//
|
|
|
// Copyright (c) 2009-2015 Math.NET
|
|
|
// Copyright (c) 2009-2018 Math.NET
|
|
|
//
|
|
|
//
|
|
|
// Permission is hereby granted, free of charge, to any person
|
|
|
// Permission is hereby granted, free of charge, to any person
|
|
|
// obtaining a copy of this software and associated documentation
|
|
|
// obtaining a copy of this software and associated documentation
|
|
|
@ -61,6 +61,26 @@ namespace MathNet.Numerics |
|
|
return z => intercept + slope*z; |
|
|
return z => intercept + slope*z; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Least-Squares fitting the points (x,y) to a line through origin y : x -> b*x,
|
|
|
|
|
|
/// returning its best fitting parameter b,
|
|
|
|
|
|
/// where the intercept is zero and b the slope.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static double LineThroughOrigin(double[] x, double[] y) |
|
|
|
|
|
{ |
|
|
|
|
|
return SimpleRegression.FitThroughOrigin(x, y); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Least-Squares fitting the points (x,y) to a line through origin y : x -> b*x,
|
|
|
|
|
|
/// returning a function y' for the best fitting line.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static Func<double, double> LineThroughOriginFunc(double[] x, double[] y) |
|
|
|
|
|
{ |
|
|
|
|
|
double slope = SimpleRegression.FitThroughOrigin(x, y); |
|
|
|
|
|
return z => slope * z; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Least-Squares fitting the points (X,y) = ((x0,x1,..,xk),y) to a linear surface y : X -> p0*x0 + p1*x1 + ... + pk*xk,
|
|
|
/// Least-Squares fitting the points (X,y) = ((x0,x1,..,xk),y) to a linear surface y : X -> p0*x0 + p1*x1 + ... + pk*xk,
|
|
|
/// returning its best fitting parameters as [p0, p1, p2, ..., pk] array.
|
|
|
/// returning its best fitting parameters as [p0, p1, p2, ..., pk] array.
|
|
|
|