Changeset 9124 for branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.Instances.DataAnalysis.GaussianProcessRegression/Util.cs
- Timestamp:
- 01/08/13 11:01:56 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GaussianProcessTuning/HeuristicLab.Problems.Instances.DataAnalysis.GaussianProcessRegression/Util.cs
r9099 r9124 31 31 32 32 33 public static List<double> SampleGaussianProcess(IRandom random, ParameterizedCovarianceFunction covFunction, List<List<double>> data) { 34 int n = data[0].Count; 33 35 34 public static List<double> SampleGaussianProcess(IRandom random, ParameterizedCovarianceFunction covFunction, List<List<double>> data) { 36 var normalRand = new NormalDistributedRandom(random, 0, 1); 37 var alpha = (from i in Enumerable.Range(0, n) 38 select normalRand.NextDouble()).ToArray(); 39 return SampleGaussianProcess(random, covFunction, data, alpha); 40 } 41 42 public static List<double> SampleGaussianProcess(IRandom random, ParameterizedCovarianceFunction covFunction, List<List<double>> data, double[] alpha) { 43 if (alpha.Length != data[0].Count) throw new ArgumentException(); 35 44 36 45 double[,] x = new double[data[0].Count, data.Count]; … … 43 52 K[i, j] = covFunction.Covariance(x, i, j); 44 53 45 var normalRand = new NormalDistributedRandom(random, 0, 1);46 47 54 if (!alglib.spdmatrixcholesky(ref K, K.GetLength(0), true)) throw new ArgumentException(); 48 var r = (from i in Enumerable.Range(0, K.GetLength(0))49 select normalRand.NextDouble()).ToArray();50 55 51 56 List<double> target = new List<double>(K.GetLength(0)); … … 54 59 for (int j = K.GetLength(0) - 1; j >= 0; j--) { 55 60 56 s += K[j, i] * r[j];61 s += K[j, i] * alpha[j]; 57 62 } 58 63
Note: See TracChangeset
for help on using the changeset viewer.