Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/MeanZero.cs @ 8323

Last change on this file since 8323 was 8323, checked in by gkronber, 12 years ago

#1902 initial import of Gaussian process regression algorithm

File size: 1.3 KB
Line 
1
2using System;
3using System.Linq;
4using HeuristicLab.Common;
5using HeuristicLab.Core;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.Algorithms.DataAnalysis.GaussianProcess {
9  [StorableClass]
10  [Item(Name = "MeanZero", Description = "Constant zero mean function for Gaussian processes.")]
11  public class MeanZero : Item, IMeanFunction {
12    [Storable]
13    private int n;
14    public int GetNumberOfParameters(int numberOfVariables) {
15      return 0;
16    }
17    [StorableConstructor]
18    protected MeanZero(bool deserializing) : base(deserializing) { }
19    protected MeanZero(MeanZero original, Cloner cloner)
20      : base(original, cloner) {
21      this.n = original.n;
22    }
23    public MeanZero() {
24    }
25
26    public void SetParameter(double[] hyp, double[,] x) {
27      if (hyp.Length > 0) throw new ArgumentException("No hyper-parameters allowed for zero mean function.", "hyp");
28      this.n = x.GetLength(0);
29    }
30
31    public double[] GetMean() {
32      return Enumerable.Repeat(0.0, n).ToArray();
33    }
34
35    public double[] GetGradients(int k) {
36      if (k > 0) throw new ArgumentException();
37      return Enumerable.Repeat(0.0, n).ToArray();
38    }
39    public override IDeepCloneable Clone(Cloner cloner) {
40      return new MeanZero(this, cloner);
41    }
42  }
43}
Note: See TracBrowser for help on using the repository browser.