Changeset 8477 for branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEard.cs
- Timestamp:
- 08/13/12 16:18:37 (12 years ago)
- Location:
- branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Algorithms.DataAnalysis merged: 8419,8421,8439,8448,8452,8455,8463-8465,8467,8471,8473,8475
- Property svn:mergeinfo changed
-
branches/HeuristicLab.TimeSeries/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSEard.cs
r8416 r8477 36 36 [Storable] 37 37 private double sf2; 38 public double Scale { get { return sf2; } } 39 38 40 [Storable] 39 41 private double[] l; 42 public double[] Length { 43 get { 44 if (l == null) return new double[0]; 45 var copy = new double[l.Length]; 46 Array.Copy(l, copy, copy.Length); 47 return copy; 48 } 49 } 40 50 41 51 private double[,] sd; … … 76 86 this.l = hyp.Take(hyp.Length - 1).Select(Math.Exp).ToArray(); 77 87 this.sf2 = Math.Exp(2 * hyp[hyp.Length - 1]); 78 sf2 = Math.Min(10E6, sf2); // upper limit for the scale88 // sf2 = Math.Min(10E6, sf2); // upper limit for the scale 79 89 80 90 sd = null; … … 99 109 } 100 110 101 public double[] GetGradient(int i, int j) { 102 var res = new double[l.Length + 1]; 103 for (int k = 0; k < l.Length; k++) { 111 public double GetGradient(int i, int j, int k) { 112 if (k < l.Length) { 104 113 double sqrDist = Util.SqrDist(x[i, k] / l[k], xt[j, k] / l[k]); 105 106 res[k] = sf2 * Math.Exp(-sd[i, j] / 2.0) * sqrDist; 114 return sf2 * Math.Exp(-sd[i, j] / 2.0) * sqrDist; 115 } else if (k == l.Length) { 116 return 2.0 * sf2 * Math.Exp(-sd[i, j] / 2.0); 117 } else { 118 throw new ArgumentException("CovarianceSEard has dimension+1 hyperparameters.", "k"); 107 119 } 108 res[res.Length - 1] = 2.0 * sf2 * Math.Exp(-sd[i, j] / 2.0);109 return res;110 120 } 111 121
Note: See TracChangeset
for help on using the changeset viewer.