private double CalculateBestPoint(double TypcalValue, double[] X, double[] Y) { bool flag = false; int i = 1; double BestDacPoint; while (!flag && i < Y.Length) { if (TypcalValue >= Y[i - 1] && TypcalValue <= Y[i]) { flag = true; break; } i++; } double slope = 0, intercept = 0; Algorithm.LinearRegression(X, Y, out slope, out intercept); BestDacPoint = slope + (intercept * TypcalValue); return(BestDacPoint); }
protected void GettingCurvingPointsandFitting(Attennuator tempAtten, ErrorDetector tempED) { lock (tempAtten) { try { double intercept; double slope; byte tmepCount = 0; Log.SaveLogToTxt("Step6...SerchCoefPoints"); { SerchCoefPoints(tempAtten, tempED, attPoint, ber_erp, testBerStruct.CoefCsenAddStep, testBerStruct.CoefCsenSubStep, out attPoints, out berPoints); tmepCount = (byte)Math.Min(attPoints.Count, berPoints.Count); double[] tempattPoints = new double[tmepCount]; double[] tempberPoints = new double[tmepCount]; for (byte i = 0; i < tmepCount; i++) { tempattPoints[i] = double.Parse(attPoints[i].ToString()); tempberPoints[i] = double.Parse(berPoints[i].ToString()); Log.SaveLogToTxt("attPoints[ " + i.ToString() + "]" + double.Parse(attPoints[i].ToString()) + " " + "berPoints[ " + i.ToString() + "]" + double.Parse(berPoints[i].ToString())); } Algorithm.LinearRegression(Algorithm.Getlog10(Algorithm.GetNegative(Algorithm.Getlog10(tempberPoints))), tempattPoints, out slope, out intercept); sensitivityPoint = slope + (intercept * System.Math.Log10(System.Math.Log10(ber_erp) * (-1))); Log.SaveLogToTxt("LinearSlope=" + intercept + " LinearOffset= " + slope);// 因为Offset 和 Slope 的幅值颠倒 Leo } } catch (System.Exception ex) { throw ex; } } }
private double CalculateBestPoint(double TypcalValue, double[] X, double[] Y) { double BestDacPoint; double slope = 0, intercept = 0; Algorithm.LinearRegression(X, Y, out slope, out intercept); BestDacPoint = slope + (intercept * TypcalValue); return(BestDacPoint); }