internal static DF AddRow(DF df, AR ts) { List <double> row = ts.ToList(); DF dfRes = AddRow(df, row); return(dfRes); }
internal Norm(AR X, double factor, double minFactor, double maxFactor) { this.factor = factor; double min = double.MaxValue; double max = double.MinValue; for (int i = 1; i < X.Length; i++) { if (X[i] < min) { min = X[i]; } if (X[i] > max) { max = X[i]; } } this.xMin = min * (1 - minFactor); this.xMax = max * (1 + maxFactor); this.xRange = this.xMax - this.xMin; if (this.xRange == 0) { this.xRange = this.xMax; } }
internal AR Clone() { AR arClone = new AR(this.Length); AR.Copy(this, arClone, 1, this.Length, 1, this.Length); return(arClone); }
internal AR Normalize(AR X) { AR nX = (X - this.xMin) / this.xRange; AR fnX = nX * this.factor; return(fnX); }
internal static AR C(AR ar1, AR ar2) { AR conc = new AR(ar1.Length + ar2.Length); Copy(ar1, conc, 1, ar1.Length, 1, ar1.Length); Copy(ar2, conc, 1, ar2.Length, ar1.Length + 1, conc.Length); return(conc); }
internal static AR C(AR ar, double x) { AR conc = new AR(ar.Length + 1); Copy(ar, conc, 1, ar.Length, 1, ar.Length); conc[conc.Length] = x; return(conc); }
internal static DF AddColumn(DF df, AR ts) { List <double> col = ts.ToList(); DF dfRes = df.Clone(); dfRes.AddColumn(col); return(dfRes); }
public static AR operator -(AR ar, double val) { AR arSub = new AR(ar.Length); for (int i = 1; i <= ar.Length; i++) { arSub[i] = ar[i] - val; } return(arSub); }
public static AR operator +(AR ar, double val) { AR arSum = new AR(ar.Length); for (int i = 1; i <= ar.Length; i++) { arSum[i] = ar[i] + val; } return(arSum); }
internal static AR Abs(AR ar) { AR arAbs = ar.Clone(); for (int i = 1; i <= ar.Length; i++) { arAbs[i] = Math.Abs(ar[i]); } return(arAbs); }
internal static AR Rep(double val, int n) { AR rep = new AR(n); for (int i = 1; i <= rep.Length; i++) { rep[i] = val; } return(rep); }
public static AR operator *(AR ar, double val) { AR arPro = new AR(ar.Length); for (int i = 1; i <= ar.Length; i++) { arPro[i] = ar[i] * val; } return(arPro); }
internal AR SubAr(int ini, int end) { int diff = end - ini; AR subar = new AR(diff + 1); for (int i = ini; i <= end; i++) { subar[i - ini + 1] = this[i]; } return(subar); }
public static AR operator /(AR ar1, AR ar2) { if (ar1.Length != ar2.Length) { throw new Exception("Error. Different size"); } AR arDiv = new AR(ar1.Length); for (int i = 1; i <= ar1.Length; i++) { arDiv[i] = ar1[i] / ar2[i]; } return(arDiv); }
internal static double Sum(AR ar1, AR ar2) { if (ar1.Length != ar2.Length) { throw new Exception("Error. Different size"); } double sum = 0; for (int i = 1; i <= ar1.Length; i++) { sum = sum + ar1[i] + ar2[i]; } return(sum); }
public static AR operator /(AR ar, double val) { if (val == 0) { throw new Exception("Error. Division by zero"); } AR arDiv = new AR(ar.Length); for (int i = 1; i <= ar.Length; i++) { arDiv[i] = ar[i] / val; } return(arDiv); }
internal static void Copy(AR arFrom, AR arTo, int iniFrom, int endFrom, int iniTo, int endTo) { if (endFrom < iniFrom || endTo < iniTo) { throw new Exception("Error. end cannot be less than ini"); } if (endFrom - iniFrom != endTo - iniTo) { throw new Exception("Error. intervals from and to are different"); } int diff = iniTo - iniFrom; for (int i = iniTo; i <= endTo; i++) { arTo[i] = arFrom[i - diff]; } }
internal void AddColumn(AR ts) { List <double> col = ts.ToList(); this.AddColumn(col); }
internal static double Sum(AR ar) { return(ar.Sum()); }
internal void AddRow(AR ts) { List <double> row = ts.ToList(); this.AddRow(row); }
internal DF(AR ts, bool isRow) : this(ts.ToArray(), isRow) { }
internal Norm(AR X) : this(X, 1, 0, 1) { }
internal AR UnNormalize(AR nX) { AR X = (nX / this.factor) * this.xRange + this.xMin; return(X); }