Changeset 14029 for branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs
- Timestamp:
- 07/08/16 14:40:02 (8 years ago)
- Location:
- branches/crossvalidation-2434
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/crossvalidation-2434
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
-
branches/crossvalidation-2434/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePeriodic.cs
r12012 r14029 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq;25 24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; … … 117 116 } 118 117 119 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int>columnIndices) {118 public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) { 120 119 double inverseLength, period, scale; 121 120 GetParameterValues(p, out scale, out period, out inverseLength); … … 145 144 } 146 145 147 148 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength, 146 private static IList<double> GetGradient(double[,] x, int i, int j, int[] columnIndices, double scale, double period, double inverseLength, 149 147 bool fixedInverseLength, bool fixedPeriod, bool fixedScale) { 150 148 double k = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period; 151 149 double gradient = Math.Sin(k) * inverseLength; 152 150 gradient *= gradient; 153 if (!fixedInverseLength) yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient; 151 var g = new List<double>(3); 152 if (!fixedInverseLength) 153 g.Add(4.0 * scale * Math.Exp(-2.0 * gradient) * gradient); 154 154 if (!fixedPeriod) { 155 155 double r = Math.Sin(k) * inverseLength; 156 yield return 2.0 * k * scale * Math.Exp(-2 * r * r) * Math.Sin(2 * k) * inverseLength * inverseLength;156 g.Add(2.0 * k * scale * Math.Exp(-2 * r * r) * Math.Sin(2 * k) * inverseLength * inverseLength); 157 157 } 158 158 if (!fixedScale) 159 yield return 2.0 * scale * Math.Exp(-2 * gradient);160 159 g.Add(2.0 * scale * Math.Exp(-2 * gradient)); 160 return g; 161 161 } 162 162 163 private static double GetDistance(double[,] x, double[,] xt, int i, int j, IEnumerable<int>columnIndices) {164 return Math.Sqrt(Util.SqrDist(x, i, xt, j, 1, columnIndices));163 private static double GetDistance(double[,] x, double[,] xt, int i, int j, int[] columnIndices) { 164 return Math.Sqrt(Util.SqrDist(x, i, xt, j, columnIndices, 1)); 165 165 } 166 166 }
Note: See TracChangeset
for help on using the changeset viewer.