Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/23/13 08:33:12 (11 years ago)
Author:
gkronber
Message:

#2032 improved identifiers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePolynomial.cs

    r9515 r9516  
    3434    Description = "Polynomial covariance function for Gaussian processes.")]
    3535  public sealed class CovariancePolynomial : ParameterizedNamedItem, ICovarianceFunction {
    36     public IValueParameter<DoubleValue> CParameter {
    37       get { return (IValueParameter<DoubleValue>)Parameters["C"]; }
     36    public IValueParameter<DoubleValue> ConstParameter {
     37      get { return (IValueParameter<DoubleValue>)Parameters["Const"]; }
    3838    }
    3939
     
    6060      Description = ItemDescription;
    6161
    62       Parameters.Add(new OptionalValueParameter<DoubleValue>("C", "Parameter for the additive constant in the polymomial."));
     62      Parameters.Add(new OptionalValueParameter<DoubleValue>("Const", "Additive constant in the polymomial."));
    6363      Parameters.Add(new OptionalValueParameter<DoubleValue>("Scale", "The scale parameter of the Polynomial covariance function."));
    6464      Parameters.Add(new ValueParameter<IntValue>("Degree", "The degree of the polynomial (only non-zero positive values allowed).", new IntValue(2)));
     
    7171    public int GetNumberOfParameters(int numberOfVariables) {
    7272      return
    73         (CParameter.Value != null ? 0 : 1) +
     73        (ConstParameter.Value != null ? 0 : 1) +
    7474        (ScaleParameter.Value != null ? 0 : 1);
    7575    }
    7676
    7777    public void SetParameter(double[] p) {
    78       double c, scale;
    79       GetParameterValues(p, out c, out scale);
    80       CParameter.Value = new DoubleValue(c);
     78      double @const, scale;
     79      GetParameterValues(p, out @const, out scale);
     80      ConstParameter.Value = new DoubleValue(@const);
    8181      ScaleParameter.Value = new DoubleValue(scale);
    8282    }
    8383
    84     private void GetParameterValues(double[] p, out double c, out double scale) {
     84    private void GetParameterValues(double[] p, out double @const, out double scale) {
    8585      // gather parameter values
    8686      int n = 0;
    87       if (CParameter.Value != null) {
    88         c = CParameter.Value.Value;
     87      if (ConstParameter.Value != null) {
     88        @const = ConstParameter.Value.Value;
    8989      } else {
    90         c = Math.Exp(p[n]);
     90        @const = Math.Exp(p[n]);
    9191        n++;
    9292      }
     
    102102
    103103    public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int> columnIndices) {
    104       double c, scale;
    105       int d = DegreeParameter.Value.Value;
    106       if (d <= 0) throw new ArgumentException("The degree parameter for CovariancePolynomial must be greater than zero.");
    107       GetParameterValues(p, out c, out scale);
     104      double @const, scale;
     105      int degree = DegreeParameter.Value.Value;
     106      if (degree <= 0) throw new ArgumentException("The degree parameter for CovariancePolynomial must be greater than zero.");
     107      GetParameterValues(p, out @const, out scale);
    108108      // create functions
    109109      var cov = new ParameterizedCovarianceFunction();
    110       cov.Covariance = (x, i, j) => scale * Math.Pow(c + Util.ScalarProd(x, i, j, 1.0, columnIndices), d);
    111       cov.CrossCovariance = (x, xt, i, j) => scale * Math.Pow(c + Util.ScalarProd(x, i, xt, j, 1.0, columnIndices), d);
    112       cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, c, scale, d, columnIndices);
     110      cov.Covariance = (x, i, j) => scale * Math.Pow(@const + Util.ScalarProd(x, i, j, 1.0, columnIndices), degree);
     111      cov.CrossCovariance = (x, xt, i, j) => scale * Math.Pow(@const + Util.ScalarProd(x, i, xt, j, 1.0, columnIndices), degree);
     112      cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, @const, scale, degree, columnIndices);
    113113      return cov;
    114114    }
Note: See TracChangeset for help on using the changeset viewer.