Changeset 8678 for trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovariancePeriodic.cs
- Timestamp:
- 09/21/12 18:45:15 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovariancePeriodic.cs
r8612 r8678 76 76 Name = ItemName; 77 77 Description = ItemDescription; 78 78 79 79 scaleParameter = new HyperParameter<DoubleValue>("Scale", "The scale of the periodic covariance function."); 80 80 inverseLengthParameter = new HyperParameter<DoubleValue>("InverseLength", "The inverse length parameter for the periodic covariance function."); … … 125 125 } 126 126 127 public double GetCovariance(double[,] x, int i, int j) { 128 double k = i == j ? 0.0 : GetDistance(x, x, i, j); 127 public double GetCovariance(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 128 if (columnIndices == null || columnIndices.Count() != 1) 129 throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); 130 double k = i == j ? 0.0 : GetDistance(x, x, i, j, columnIndices); 129 131 k = Math.PI * k / period; 130 132 k = Math.Sin(k) * inverseLength; … … 134 136 } 135 137 136 public IEnumerable<double> GetGradient(double[,] x, int i, int j) { 137 double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j) / period; 138 public IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices) { 139 if (columnIndices == null || columnIndices.Count() != 1) 140 throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); 141 double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period; 138 142 double gradient = Math.Sin(v) * inverseLength; 139 143 gradient *= gradient; … … 144 148 } 145 149 146 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { 147 double k = GetDistance(x, xt, i, j); 150 public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 151 if (columnIndices == null || columnIndices.Count() != 1) 152 throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); 153 double k = GetDistance(x, xt, i, j, columnIndices); 148 154 k = Math.PI * k / period; 149 155 k = Math.Sin(k) * inverseLength; … … 153 159 } 154 160 155 private double GetDistance(double[,] x, double[,] xt, int i, int j ) {156 return Math.Sqrt(Util.SqrDist(x, i, xt, j ));161 private double GetDistance(double[,] x, double[,] xt, int i, int j, IEnumerable<int> columnIndices) { 162 return Math.Sqrt(Util.SqrDist(x, i, xt, j, 1, columnIndices)); 157 163 } 158 164 }
Note: See TracChangeset
for help on using the changeset viewer.