Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/02/16 14:38:40 (8 years ago)
Author:
gkronber
Message:

#2591: merged r13438 (#2541), r13721, r13724, r13784, r13891 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.DataAnalysis

  • stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovariancePiecewisePolynomial.cs

    r12009 r13981  
    6969      Parameters.Add(new OptionalValueParameter<DoubleValue>("Scale", "The scale parameter of the piecewise polynomial covariance function."));
    7070
    71       var validValues = new ItemSet<IntValue>(new IntValue[] { 
    72         (IntValue)(new IntValue().AsReadOnly()), 
    73         (IntValue)(new IntValue(1).AsReadOnly()), 
    74         (IntValue)(new IntValue(2).AsReadOnly()), 
     71      var validValues = new ItemSet<IntValue>(new IntValue[] {
     72        (IntValue)(new IntValue().AsReadOnly()),
     73        (IntValue)(new IntValue(1).AsReadOnly()),
     74        (IntValue)(new IntValue(2).AsReadOnly()),
    7575        (IntValue)(new IntValue(3).AsReadOnly()) });
    7676      Parameters.Add(new ConstrainedValueParameter<IntValue>("V", "The v parameter of the piecewise polynomial function (allowed values 0, 1, 2, 3).", validValues, validValues.First()));
     
    113113    }
    114114
    115     public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, IEnumerable<int> columnIndices) {
     115    public ParameterizedCovarianceFunction GetParameterizedCovarianceFunction(double[] p, int[] columnIndices) {
    116116      double length, scale;
    117117      int v = VParameter.Value.Value;
     
    148148      var cov = new ParameterizedCovarianceFunction();
    149149      cov.Covariance = (x, i, j) => {
    150         double k = Math.Sqrt(Util.SqrDist(x, i, x, j, 1.0 / length, columnIndices));
     150        double k = Math.Sqrt(Util.SqrDist(x, i, x, j, columnIndices, 1.0 / length));
    151151        return scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
    152152      };
    153153      cov.CrossCovariance = (x, xt, i, j) => {
    154         double k = Math.Sqrt(Util.SqrDist(x, i, xt, j, 1.0 / length, columnIndices));
     154        double k = Math.Sqrt(Util.SqrDist(x, i, xt, j, columnIndices, 1.0 / length));
    155155        return scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
    156156      };
     
    159159    }
    160160
    161     private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double length, double scale, int v, double exp, Func<double, double> f, Func<double, double> df, IEnumerable<int> columnIndices,
     161    private static IList<double> GetGradient(double[,] x, int i, int j, double length, double scale, int v, double exp, Func<double, double> f, Func<double, double> df, int[] columnIndices,
    162162      bool fixedLength, bool fixedScale) {
    163       double k = Math.Sqrt(Util.SqrDist(x, i, x, j, 1.0 / length, columnIndices));
    164       if (!fixedLength) yield return scale * Math.Pow(Math.Max(1.0 - k, 0), exp + v - 1) * k * ((exp + v) * f(k) - Math.Max(1 - k, 0) * df(k));
    165       if (!fixedScale) yield return 2.0 * scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k);
     163      double k = Math.Sqrt(Util.SqrDist(x, i, x, j, columnIndices, 1.0 / length));
     164      var g = new List<double>(2);
     165      if (!fixedLength) g.Add(scale * Math.Pow(Math.Max(1.0 - k, 0), exp + v - 1) * k * ((exp + v) * f(k) - Math.Max(1 - k, 0) * df(k)));
     166      if (!fixedScale) g.Add(2.0 * scale * Math.Pow(Math.Max(1 - k, 0), exp + v) * f(k));
     167      return g;
    166168    }
    167169  }
Note: See TracChangeset for help on using the changeset viewer.