- Timestamp:
- 08/08/12 17:52:27 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProd.cs
r8416 r8439 87 87 88 88 public double[] GetGradient(int i, int j) { 89 return factors.Select(t => t.GetGradient(i, j)).SelectMany(seq => seq).ToArray(); 89 return Enumerable.Range(0, GetNumberOfParameters(numberOfVariables)).Select(k => GetGradient(i, j, k)).ToArray(); 90 } 91 public double GetGradient(int i, int j, int k) { 92 // map from parameter index to factor 93 var vi = factors.Select((f, idx) => Enumerable.Repeat(idx, f.GetNumberOfParameters(numberOfVariables))).SelectMany(x => x).ToArray(); 94 double res = 1.0; 95 int jj = Enumerable.Range(0, k).Count(e => vi[e] == vi[k]); 96 for (int ii = 0; ii < factors.Count; ii++) { 97 var f = factors[ii]; 98 if (ii == vi[k]) { 99 res *= f.GetGradient(i, j)[jj]; 100 } else { 101 res *= f.GetCovariance(i, j); 102 } 103 } 104 return res; 90 105 } 91 106 }
Note: See TracChangeset
for help on using the changeset viewer.