From 74eb5e967b9fbbde1de0d5a86f606c564ecd79bc Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Fri, 16 Feb 2018 19:43:08 +0100 Subject: [PATCH] Fit: minor code cleanup --- src/Numerics/Fit.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Numerics/Fit.cs b/src/Numerics/Fit.cs index c8ded4e0..34d8a0cf 100644 --- a/src/Numerics/Fit.cs +++ b/src/Numerics/Fit.cs @@ -88,9 +88,9 @@ namespace MathNet.Numerics public static Tuple Exponential(double[] x, double[] y, DirectRegressionMethod method = DirectRegressionMethod.QR) { // Transformation: y_h := ln(y) ~> y_h : x -> ln(a) + r*x; - double[] y_hat = Generate.Map(y, Math.Log); - double[] p_hat = Fit.LinearCombination(x, y_hat, method, t => 1.0, t => t); - return Tuple.Create(Math.Exp(p_hat[0]), p_hat[1]); + double[] lny = Generate.Map(y, Math.Log); + double[] p = LinearCombination(x, lny, method, t => 1.0, t => t); + return Tuple.Create(Math.Exp(p[0]), p[1]); } /// @@ -112,7 +112,7 @@ namespace MathNet.Numerics public static Tuple Logarithm(double[] x, double[] y, DirectRegressionMethod method = DirectRegressionMethod.QR) { double[] lnx = Generate.Map(x, Math.Log); - double[] p = Fit.LinearCombination(lnx, y, method, t => 1.0, t => t); + double[] p = LinearCombination(lnx, y, method, t => 1.0, t => t); return Tuple.Create(p[0], p[1]); } @@ -135,9 +135,9 @@ namespace MathNet.Numerics public static Tuple Power(double[] x, double[] y, DirectRegressionMethod method = DirectRegressionMethod.QR) { // Transformation: y_h := ln(y) ~> y_h : x -> ln(a) + b*ln(x); - double[] y_hat = Generate.Map(y, Math.Log); - double[] p_hat = Fit.LinearCombination(x, y_hat, method, t => 1.0, Math.Log); - return Tuple.Create(Math.Exp(p_hat[0]), p_hat[1]); + double[] lny = Generate.Map(y, Math.Log); + double[] p = LinearCombination(x, lny, method, t => 1.0, Math.Log); + return Tuple.Create(Math.Exp(p[0]), p[1]); } ///