Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/04/13 16:06:26 (11 years ago)
Author:
gkronber
Message:

#1902 fixed bugs in ARD covariance functions (checked if parameter and gradient order matches for all functions)

File:
1 edited

Legend:

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

    r9106 r9108  
    7676      int c = 0;
    7777      // gather parameter values
     78      if (InverseLengthParameter.Value != null) {
     79        inverseLength = InverseLengthParameter.Value.ToArray();
     80      } else {
     81        int length = p.Length;
     82        if (ScaleParameter.Value == null) length--;
     83        inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray();
     84        c += inverseLength.Length;
     85      }
    7886      if (ScaleParameter.Value != null) {
    7987        scale = ScaleParameter.Value.Value;
     
    8189        scale = Math.Exp(2 * p[c]);
    8290        c++;
    83       }
    84       if (InverseLengthParameter.Value != null) {
    85         inverseLength = InverseLengthParameter.Value.ToArray();
    86       } else {
    87         inverseLength = p.Skip(c).Select(e => 1.0 / Math.Exp(e)).ToArray();
    88         c += inverseLength.Length;
    8991      }
    9092      if (p.Length != c) throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovarianceSquaredExponentialArd", "p");
     
    111113    }
    112114
    113 
     115    // order of returned gradients must match the order in GetParameterValues!
    114116    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double[] inverseLength) {
    115117      if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1));
     
    117119                   ? 0.0
    118120                   : Util.SqrDist(x, i, j, inverseLength, columnIndices);
     121
    119122      int k = 0;
    120123      foreach (var columnIndex in columnIndices) {
     
    123126        k++;
    124127      }
    125 
    126128      yield return 2.0 * scale * Math.Exp(-d / 2.0);
    127129    }
Note: See TracChangeset for help on using the changeset viewer.