/// <summary> /// 获取结果 /// </summary> /// <param name="time"></param> /// <returns></returns> public double GetY(Time time) { if (LsPolyFit == null) { throw new Exception("请Init初始化先!"); } double xValue = time - FirstTime; return(LsPolyFit.GetY(xValue)); }
/// <summary> /// 获取最小二乘多项式拟合。 /// </summary> /// <param name="order"></param> /// <returns></returns> public LsPolyFit GetLsPolyFit(int order) { var len = this.Count; double[] yArray = this.Data.ToArray(); double[] xArray = new double[len]; for (int i = 0; i < len; i++) { xArray[i] = i; } Geo.Algorithm.LsPolyFit fit = new Geo.Algorithm.LsPolyFit(xArray, yArray, order); double[] paralist = fit.FitParameters(); return(fit); }
/// <summary> /// 多项式拟合。 /// 参数与乘积为从低到高。 /// 注意:拟合参数数量 = 阶次 + 1 /// </summary> /// <param name="arrayX">数组</param> /// <param name="arrayY">数组</param> /// <param name="order">阶次</param> /// <returns>拟合参数</returns> public static double[] GetFitParams(double[] arrayX, double[] arrayY, int order) { LsPolyFit fit = new LsPolyFit(arrayX, arrayY, order); return(fit.FitParameters()); }
/// <summary> /// 字符串显示 /// </summary> /// <returns></returns> public override string ToString() { return(LsPolyFit.ToString()); }
/// <summary> /// 初始化 /// </summary> public void Init() { LsPolyFit = new LsPolyFit(this.Order); LsPolyFit.InitAndFitParams <double>(DicData, m => m); }