Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8582


Ignore:
Timestamp:
09/05/12 17:04:30 (12 years ago)
Author:
gkronber
Message:

#1902 implemented a few covariance functions as parameterized named items. Implemented rudimentary view for Gaussian process models.

Location:
trunk/sources
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GaussianProcessModelView.Designer.cs

    r8416 r8582  
    1919 */
    2020#endregion
     21
     22using HeuristicLab.Optimization.Views;
    2123
    2224namespace HeuristicLab.Algorithms.DataAnalysis.Views {
     
    4547    /// </summary>
    4648    private void InitializeComponent() {
     49      this.resultCollectionView = new ResultCollectionView();
    4750      this.SuspendLayout();
     51      //
     52      // resultCollectionView
     53      //
     54      this.resultCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
     55      this.resultCollectionView.Location = new System.Drawing.Point(0, 0);
     56      this.resultCollectionView.Name = "resultCollectionView";
     57      this.resultCollectionView.Size = new System.Drawing.Size(253, 251);
     58      this.resultCollectionView.TabIndex = 0;
    4859      //
    4960      // GaussianProcessModelView
     
    5162      this.AllowDrop = true;
    5263      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     64      this.Controls.Add(this.resultCollectionView);
    5365      this.Name = "GaussianProcessModelView";
    5466      this.Size = new System.Drawing.Size(253, 251);
     
    5971    #endregion
    6072
    61 
     73    private ResultCollectionView resultCollectionView;
    6274
    6375  }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GaussianProcessModelView.cs

    r8416 r8582  
    2121
    2222using System.Windows.Forms;
     23using HeuristicLab.Data;
    2324using HeuristicLab.MainForm;
    2425using HeuristicLab.MainForm.WindowsForms;
     26using HeuristicLab.Optimization;
    2527
    2628namespace HeuristicLab.Algorithms.DataAnalysis.Views {
     
    3133    public new IGaussianProcessModel Content {
    3234      get { return (IGaussianProcessModel)base.Content; }
    33       set { base.Content = value; }
     35      set {
     36        base.Content = value;
     37      }
    3438    }
    3539
     
    4347      if (Content == null) {
    4448        // clear
     49        resultCollectionView.Content = null;
    4550      } else {
    46         // update
     51        resultCollectionView.Content = CreateResultCollection(Content);
    4752      }
     53    }
     54
     55    private ResultCollection CreateResultCollection(IGaussianProcessModel gaussianProcessModel) {
     56      var res = new ResultCollection();
     57      res.Add(new Result("Mean Function", gaussianProcessModel.MeanFunction));
     58      res.Add(new Result("Covariance Function", gaussianProcessModel.CovarianceFunction));
     59      res.Add(new Result("Noise sigma", new DoubleValue(gaussianProcessModel.SigmaNoise)));
     60      return res;
    4861    }
    4962  }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceConst.cs

    r8484 r8582  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
     
    3031  [Item(Name = "CovarianceConst",
    3132    Description = "Constant covariance function for Gaussian processes.")]
    32   public class CovarianceConst : Item, ICovarianceFunction {
     33  public class CovarianceConst : CovarianceFunction {
     34
     35    public IValueParameter<DoubleValue> ScaleParameter {
     36      get { return scaleParameter; }
     37    }
     38
    3339    [Storable]
    34     private double sf2;
    35     public double Scale { get { return sf2; } }
     40    private readonly HyperParameter<DoubleValue> scaleParameter;
     41
     42    [Storable]
     43    private double scale;
    3644
    3745    [StorableConstructor]
     
    4250    protected CovarianceConst(CovarianceConst original, Cloner cloner)
    4351      : base(original, cloner) {
    44       this.sf2 = original.sf2;
     52      this.scaleParameter = cloner.Clone(original.scaleParameter);
     53      this.scale = original.scale;
     54
     55      RegisterEvents();
    4556    }
    4657
    4758    public CovarianceConst()
    4859      : base() {
     60      scaleParameter = new HyperParameter<DoubleValue>("Scale", "The scale of the constant covariance function.");
     61      Parameters.Add(scaleParameter);
     62      RegisterEvents();
    4963    }
     64
     65    [StorableHook(HookType.AfterDeserialization)]
     66    private void AfterDeserialization() {
     67      RegisterEvents();
     68    }
     69
     70    // caching
     71    private void RegisterEvents() {
     72      AttachValueChangeHandler<DoubleValue, double>(scaleParameter, () => { scale = scaleParameter.Value.Value; });
     73    }
     74
    5075
    5176    public override IDeepCloneable Clone(Cloner cloner) {
     
    5378    }
    5479
    55     public int GetNumberOfParameters(int numberOfVariables) {
    56       return 1;
     80    public override int GetNumberOfParameters(int numberOfVariables) {
     81      return scaleParameter.Fixed ? 0 : 1;
    5782    }
    5883
    59     public void SetParameter(double[] hyp) {
    60       if (hyp.Length != 1) throw new ArgumentException("CovarianceConst has only one hyperparameter", "k");
    61       this.sf2 = Math.Exp(2 * hyp[0]);
     84    public override void SetParameter(double[] hyp) {
     85      if (!scaleParameter.Fixed && hyp.Length == 1) {
     86        scaleParameter.SetValue(new DoubleValue(Math.Exp(2 * hyp[0])));
     87      } else {
     88        throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovarianceConst", "hyp");
     89      }
    6290    }
    6391
    64 
    65     public double GetCovariance(double[,] x, int i, int j) {
    66       return sf2;
     92    public override double GetCovariance(double[,] x, int i, int j) {
     93      return scale;
    6794    }
    6895
    69     public IEnumerable<double> GetGradient(double[,] x, int i, int j) {
    70       yield return 2 * sf2;
     96    public override IEnumerable<double> GetGradient(double[,] x, int i, int j) {
     97      yield return 2.0 * scale;
    7198    }
    7299
    73     public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
    74       return sf2;
     100    public override double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
     101      return scale;
    75102    }
    76103  }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinear.cs

    r8562 r8582  
    2929  [StorableClass]
    3030  [Item(Name = "CovarianceLinear", Description = "Linear covariance function for Gaussian processes.")]
    31   public class CovarianceLinear : Item, ICovarianceFunction {
    32     public int GetNumberOfParameters(int numberOfVariables) {
     31  public class CovarianceLinear : CovarianceFunction {
     32    public override int GetNumberOfParameters(int numberOfVariables) {
    3333      return 0;
    3434    }
     
    4646    }
    4747
    48     public void SetParameter(double[] hyp) {
     48    public override void SetParameter(double[] hyp) {
    4949      if (hyp.Length > 0) throw new ArgumentException("No hyperparameters are allowed for the linear covariance function.");
    5050    }
    5151
    52     public double GetCovariance(double[,] x, int i, int j) {
     52    public override double GetCovariance(double[,] x, int i, int j) {
    5353      return Util.ScalarProd(x, i, j);
    5454    }
    5555
    56     public IEnumerable<double> GetGradient(double[,] x, int i, int j) {
     56    public override IEnumerable<double> GetGradient(double[,] x, int i, int j) {
    5757      yield break;
    5858    }
    5959
    60     public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
     60    public override double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
    6161      return Util.ScalarProd(x, i, xt, j);
    6262    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinearArd.cs

    r8562 r8582  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
     
    3132  [Item(Name = "CovarianceLinearArd",
    3233    Description = "Linear covariance function with automatic relevance determination for Gaussian processes.")]
    33   public class CovarianceLinearArd : Item, ICovarianceFunction {
     34  public class CovarianceLinearArd : CovarianceFunction {
     35    public IValueParameter<DoubleArray> InverseLengthParameter {
     36      get { return inverseLengthParameter; }
     37    }
     38
     39    [Storable]
     40    private HyperParameter<DoubleArray> inverseLengthParameter;
     41
    3442    [Storable]
    3543    private double[] inverseLength;
    36     public double[] InverseLength {
    37       get {
    38         if (inverseLength == null) return null;
    39         double[] res = new double[inverseLength.Length];
    40         Array.Copy(inverseLength, res, res.Length);
    41         return res;
    42       }
    43     }
    44 
    45     public int GetNumberOfParameters(int numberOfVariables) {
    46       return numberOfVariables;
    47     }
    4844
    4945    [StorableConstructor]
     
    5147    protected CovarianceLinearArd(CovarianceLinearArd original, Cloner cloner)
    5248      : base(original, cloner) {
    53       this.inverseLength = original.InverseLength;  // array is copied in the getter
     49      inverseLengthParameter = cloner.Clone(original.inverseLengthParameter);
     50      if (original.inverseLength != null) {
     51        this.inverseLength = new double[original.inverseLength.Length];
     52        Array.Copy(original.inverseLength, inverseLength, inverseLength.Length);
     53      }
     54
     55      RegisterEvents();
    5456    }
    5557    public CovarianceLinearArd()
    5658      : base() {
     59      inverseLengthParameter = new HyperParameter<DoubleArray>("InverseLength",
     60                                                               "The inverse length parameter for ARD.");
     61      Parameters.Add(inverseLengthParameter);
     62      RegisterEvents();
     63    }
     64
     65    [StorableHook(HookType.AfterDeserialization)]
     66    private void AfterDeserialization() {
     67      RegisterEvents();
    5768    }
    5869
     
    6172    }
    6273
    63     public void SetParameter(double[] hyp) {
    64       inverseLength = hyp.Select(e => 1.0 / Math.Exp(e)).ToArray();
     74    // caching
     75    private void RegisterEvents() {
     76      AttachArrayChangeHandler<DoubleArray, double>(inverseLengthParameter, () => { inverseLength = inverseLengthParameter.Value.ToArray(); });
    6577    }
    6678
    67     public double GetCovariance(double[,] x, int i, int j) {
     79
     80    public override int GetNumberOfParameters(int numberOfVariables) {
     81      if (!inverseLengthParameter.Fixed)
     82        return numberOfVariables;
     83      else
     84        return 0;
     85    }
     86
     87    public override void SetParameter(double[] hyp) {
     88      if (!inverseLengthParameter.Fixed && hyp.Length > 0) {
     89        inverseLengthParameter.SetValue(new DoubleArray(hyp.Select(e => 1.0 / Math.Exp(e)).ToArray()));
     90      } else throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovarianceLinearArd", "hyp");
     91    }
     92
     93    public override double GetCovariance(double[,] x, int i, int j) {
    6894      return Util.ScalarProd(x, i, j, inverseLength);
    6995    }
    7096
    71     public IEnumerable<double> GetGradient(double[,] x, int i, int j) {
     97    public override IEnumerable<double> GetGradient(double[,] x, int i, int j) {
    7298      for (int k = 0; k < inverseLength.Length; k++) {
    7399        yield return -2.0 * x[i, k] * x[j, k] * inverseLength[k] * inverseLength[k];
     
    75101    }
    76102
    77     public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
     103    public override double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
    78104      return Util.ScalarProd(x, i, xt, j, inverseLength);
    79105    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceMaternIso.cs

    r8562 r8582  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     27using HeuristicLab.Data;
     28using HeuristicLab.Parameters;
    2629using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2730
     
    3033  [Item(Name = "CovarianceMaternIso",
    3134    Description = "Matern covariance function for Gaussian processes.")]
    32   public class CovarianceMaternIso : Item, ICovarianceFunction {
     35  public class CovarianceMaternIso : CovarianceFunction {
     36    public IValueParameter<DoubleValue> ScaleParameter {
     37      get { return scaleParameter; }
     38    }
     39    public IValueParameter<DoubleValue> InverseLengthParameter {
     40      get { return inverseLengthParameter; }
     41    }
     42    public IConstrainedValueParameter<IntValue> DParameter {
     43      get { return dParameter; }
     44    }
     45
     46    [Storable]
     47    private readonly HyperParameter<DoubleValue> inverseLengthParameter;
     48    [Storable]
     49    private readonly HyperParameter<DoubleValue> scaleParameter;
     50    [Storable]
     51    private readonly ConstrainedValueParameter<IntValue> dParameter;
     52
     53    [Storable]
     54    private double inverseLength;
    3355    [Storable]
    3456    private double sf2;
    35     public double Scale { get { return sf2; } }
    36     [Storable]
    37     private double inverseLength;
    38     public double InverseLength { get { return inverseLength; } }
    3957    [Storable]
    4058    private int d;
    41     public int D {
    42       get { return d; }
    43       set {
    44         if (value == 1 || value == 3 || value == 5) d = value;
    45         else throw new ArgumentException("D can only take the values 1, 3, or 5");
    46       }
    47     }
    4859
    4960    [StorableConstructor]
     
    5465    protected CovarianceMaternIso(CovarianceMaternIso original, Cloner cloner)
    5566      : base(original, cloner) {
     67      this.scaleParameter = cloner.Clone(original.scaleParameter);
    5668      this.sf2 = original.sf2;
     69      this.inverseLengthParameter = cloner.Clone(original.inverseLengthParameter);
    5770      this.inverseLength = original.inverseLength;
     71      this.dParameter = cloner.Clone(original.dParameter);
    5872      this.d = original.d;
     73      RegisterEvents();
    5974    }
    6075
    6176    public CovarianceMaternIso()
    6277      : base() {
    63       d = 1;
     78      inverseLengthParameter = new HyperParameter<DoubleValue>("InverseLength", "The inverse length parameter of the isometric Matern covariance function.");
     79      scaleParameter = new HyperParameter<DoubleValue>("Scale", "The scale parameter of the isometric Matern covariance function.");
     80      var validDValues = new ItemSet<IntValue>();
     81      validDValues.Add((IntValue)new IntValue(1).AsReadOnly());
     82      validDValues.Add((IntValue)new IntValue(3).AsReadOnly());
     83      validDValues.Add((IntValue)new IntValue(5).AsReadOnly());
     84      dParameter = new ConstrainedValueParameter<IntValue>("D", "The d parameter (allowed values: 1, 3, or 5) of the isometric Matern covariance function.", validDValues, validDValues.First());
     85
     86      Parameters.Add(inverseLengthParameter);
     87      Parameters.Add(scaleParameter);
     88      Parameters.Add(dParameter);
     89
     90      RegisterEvents();
     91    }
     92
     93    [StorableHook(HookType.AfterDeserialization)]
     94    private void AfterDeserialization() {
     95      RegisterEvents();
    6496    }
    6597
     
    68100    }
    69101
    70     public int GetNumberOfParameters(int numberOfVariables) {
    71       return 2;
     102    // caching
     103    private void RegisterEvents() {
     104      AttachValueChangeHandler<DoubleValue, double>(inverseLengthParameter, () => { inverseLength = inverseLengthParameter.Value.Value; });
     105      AttachValueChangeHandler<DoubleValue, double>(scaleParameter, () => { sf2 = scaleParameter.Value.Value; });
     106      AttachValueChangeHandler<IntValue, int>(dParameter, () => { d = dParameter.Value.Value; });
    72107    }
    73108
    74     public void SetParameter(double[] hyp) {
    75       if (hyp.Length != 2) throw new ArgumentException("CovarianceMaternIso has two hyperparameters", "hyp");
    76       this.inverseLength = 1.0 / Math.Exp(hyp[0]);
    77       this.sf2 = Math.Exp(2 * hyp[1]);
     109    public override int GetNumberOfParameters(int numberOfVariables) {
     110      return
     111        (inverseLengthParameter.Fixed ? 0 : 1) +
     112        (scaleParameter.Fixed ? 0 : 1);
     113    }
     114
     115    public override void SetParameter(double[] hyp) {
     116      int i = 0;
     117      if (!inverseLengthParameter.Fixed) {
     118        inverseLengthParameter.SetValue(new DoubleValue(1.0 / Math.Exp(hyp[i])));
     119        i++;
     120      }
     121      if (!scaleParameter.Fixed) {
     122        scaleParameter.SetValue(new DoubleValue(Math.Exp(2 * hyp[i])));
     123        i++;
     124      }
     125      if (hyp.Length != i) throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovarianceMaternIso", "hyp");
    78126    }
    79127
     
    101149    }
    102150
    103     public double GetCovariance(double[,] x, int i, int j) {
     151    public override double GetCovariance(double[,] x, int i, int j) {
    104152      double dist = i == j
    105153                   ? 0.0
     
    108156    }
    109157
    110     public IEnumerable<double> GetGradient(double[,] x, int i, int j) {
     158    public override IEnumerable<double> GetGradient(double[,] x, int i, int j) {
    111159      double dist = i == j
    112160                   ? 0.0
     
    117165    }
    118166
    119     public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
     167    public override double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
    120168      double dist = Math.Sqrt(Util.SqrDist(x, i, xt, j, Math.Sqrt(d) * inverseLength));
    121169      return sf2 * m(dist);
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovariancePeriodic.cs

    r8491 r8582  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    2931  [StorableClass]
    3032  [Item(Name = "CovariancePeriodic", Description = "Periodic covariance function for Gaussian processes.")]
    31   public class CovariancePeriodic : Item, ICovarianceFunction {
     33  public class CovariancePeriodic : CovarianceFunction {
     34    public IValueParameter<DoubleValue> ScaleParameter {
     35      get { return scaleParameter; }
     36    }
     37    public IValueParameter<DoubleValue> InverseLengthParameter {
     38      get { return inverseLengthParameter; }
     39    }
     40    public IValueParameter<DoubleValue> PeriodParameter {
     41      get { return periodParameter; }
     42    }
     43
    3244    [Storable]
    33     private double sf2;
    34     public double Scale { get { return sf2; } }
     45    private HyperParameter<DoubleValue> scaleParameter;
     46    [Storable]
     47    private HyperParameter<DoubleValue> inverseLengthParameter;
     48    [Storable]
     49    private HyperParameter<DoubleValue> periodParameter;
     50
     51    [Storable]
     52    private double scale;
    3553    [Storable]
    3654    private double inverseLength;
    37     public double InverseLength { get { return inverseLength; } }
    3855    [Storable]
    39     private double p;
    40     public double Period { get { return p; } }
     56    private double period;
    4157
    42     public int GetNumberOfParameters(int numberOfVariables) {
    43       return 3;
    44     }
     58
    4559    [StorableConstructor]
    4660    protected CovariancePeriodic(bool deserializing) : base(deserializing) { }
    4761    protected CovariancePeriodic(CovariancePeriodic original, Cloner cloner)
    4862      : base(original, cloner) {
    49       sf2 = original.sf2;
    50       inverseLength = original.inverseLength;
    51       p = original.p;
     63      this.scaleParameter = cloner.Clone(original.scaleParameter);
     64      this.inverseLengthParameter = cloner.Clone(original.inverseLengthParameter);
     65      this.periodParameter = cloner.Clone(original.periodParameter);
     66      this.scale = original.scale;
     67      this.inverseLength = original.inverseLength;
     68      this.period = original.period;
     69
     70      RegisterEvents();
    5271    }
     72
    5373    public CovariancePeriodic()
    5474      : base() {
     75      scaleParameter = new HyperParameter<DoubleValue>("Scale", "The scale of the periodic covariance function.");
     76      inverseLengthParameter = new HyperParameter<DoubleValue>("InverseLength", "The inverse length parameter for the periodic covariance function.");
     77      periodParameter = new HyperParameter<DoubleValue>("Period", "The period parameter for the periodic covariance function.");
     78      Parameters.Add(scaleParameter);
     79      Parameters.Add(inverseLengthParameter);
     80      Parameters.Add(periodParameter);
     81
     82      RegisterEvents();
     83    }
     84
     85    [StorableHook(HookType.AfterDeserialization)]
     86    private void AfterDeserialization() {
     87      RegisterEvents();
    5588    }
    5689
     
    5992    }
    6093
    61     public void SetParameter(double[] hyp) {
    62       if (hyp.Length != 3) throw new ArgumentException();
    63       this.inverseLength = 1.0 / Math.Exp(hyp[0]);
    64       this.p = Math.Exp(hyp[1]);
    65       this.sf2 = Math.Exp(2 * hyp[2]);
     94    // caching
     95    private void RegisterEvents() {
     96      AttachValueChangeHandler<DoubleValue, double>(scaleParameter, () => { scale = scaleParameter.Value.Value; });
     97      AttachValueChangeHandler<DoubleValue, double>(inverseLengthParameter, () => { inverseLength = inverseLengthParameter.Value.Value; });
     98      AttachValueChangeHandler<DoubleValue, double>(periodParameter, () => { period = periodParameter.Value.Value; });
    6699    }
    67100
    68     public double GetCovariance(double[,] x, int i, int j) {
     101    public override int GetNumberOfParameters(int numberOfVariables) {
     102      return
     103        (new[] { scaleParameter, inverseLengthParameter, periodParameter }).Count(p => !p.Fixed);
     104    }
     105
     106    public override void SetParameter(double[] hyp) {
     107      int i = 0;
     108      if (!inverseLengthParameter.Fixed) {
     109        inverseLengthParameter.SetValue(new DoubleValue(1.0 / Math.Exp(hyp[i])));
     110        i++;
     111      }
     112      if (!periodParameter.Fixed) {
     113        periodParameter.SetValue(new DoubleValue(Math.Exp(hyp[i])));
     114        i++;
     115      }
     116      if (!scaleParameter.Fixed) {
     117        scaleParameter.SetValue(new DoubleValue(Math.Exp(2 * hyp[i])));
     118        i++;
     119      }
     120      if (hyp.Length != i) throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovariancePeriod", "hyp");
     121    }
     122
     123    public override double GetCovariance(double[,] x, int i, int j) {
    69124      double k = i == j ? 0.0 : GetDistance(x, x, i, j);
    70       k = Math.PI * k / p;
     125      k = Math.PI * k / period;
    71126      k = Math.Sin(k) * inverseLength;
    72127      k = k * k;
    73128
    74       return sf2 * Math.Exp(-2.0 * k);
     129      return scale * Math.Exp(-2.0 * k);
    75130    }
    76131
    77     public IEnumerable<double> GetGradient(double[,] x, int i, int j) {
    78       double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j) / p;
     132    public override IEnumerable<double> GetGradient(double[,] x, int i, int j) {
     133      double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j) / period;
    79134      double gradient = Math.Sin(v) * inverseLength;
    80135      gradient *= gradient;
    81       yield return 4.0 * sf2 * Math.Exp(-2.0 * gradient) * gradient;
     136      yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient;
    82137      double r = Math.Sin(v) * inverseLength;
    83       yield return 4.0 * sf2 * inverseLength * Math.Exp(-2 * r * r) * r * Math.Cos(v) * v;
    84       yield return 2.0 * sf2 * Math.Exp(-2 * gradient);
     138      yield return 4.0 * scale * inverseLength * Math.Exp(-2 * r * r) * r * Math.Cos(v) * v;
     139      yield return 2.0 * scale * Math.Exp(-2 * gradient);
    85140    }
    86141
    87     public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
     142    public override double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) {
    88143      double k = GetDistance(x, xt, i, j);
    89       k = Math.PI * k / p;
     144      k = Math.PI * k / period;
    90145      k = Math.Sin(k) * inverseLength;
    91146      k = k * k;
    92147
    93       return sf2 * Math.Exp(-2.0 * k);
     148      return scale * Math.Exp(-2.0 * k);
    94149    }
    95150
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessModel.cs

    r8528 r8582  
    7676    [Storable]
    7777    private double sqrSigmaNoise;
     78    public double SigmaNoise {
     79      get { return Math.Sqrt(sqrSigmaNoise); }
     80    }
    7881
    7982    [Storable]
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r8565 r8582  
    120120    </Compile>
    121121    <Compile Include="FixedDataAnalysisAlgorithm.cs" />
     122    <Compile Include="GaussianProcess\HyperParameter.cs" />
     123    <Compile Include="GaussianProcess\CovarianceFunction.cs" />
    122124    <Compile Include="GaussianProcess\CovarianceRQArd.cs" />
    123125    <Compile Include="GaussianProcess\CovarianceMaternIso.cs" />
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/Interfaces/IGaussianProcessModel.cs

    r8484 r8582  
    2929  public interface IGaussianProcessModel : IRegressionModel {
    3030    double NegativeLogLikelihood { get; }
     31    double SigmaNoise { get; }
    3132    IMeanFunction MeanFunction { get; }
    3233    ICovarianceFunction CovarianceFunction { get; }
Note: See TracChangeset for help on using the changeset viewer.