Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9108


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)

Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions
Files:
5 edited

Legend:

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

    r8982 r9108  
    8282
    8383
    84     private void GetParameterValues(double[] p, out double scale, out double period, out double inverseLength) {
     84    private void GetParameterValues(double[]
     85      p, out double scale, out double period, out double inverseLength) {
    8586      // gather parameter values
    8687      int c = 0;
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticArd.cs

    r9106 r9108  
    8888      int c = 0;
    8989      // gather parameter values
     90      if (InverseLengthParameter.Value != null) {
     91        inverseLength = InverseLengthParameter.Value.ToArray();
     92      } else {
     93        int length = p.Length;
     94        if (ScaleParameter.Value == null) length--;
     95        if (ShapeParameter.Value == null) length--;
     96        inverseLength = p.Select(e => 1.0 / Math.Exp(e)).Take(length).ToArray();
     97        c += inverseLength.Length;
     98      }
    9099      if (ScaleParameter.Value != null) {
    91100        scale = ScaleParameter.Value.Value;
     
    99108        shape = Math.Exp(p[c]);
    100109        c++;
    101       }
    102       if (InverseLengthParameter.Value != null) {
    103         inverseLength = InverseLengthParameter.Value.ToArray();
    104       } else {
    105         inverseLength = p.Skip(c).Select(e => 1.0 / Math.Exp(e)).ToArray();
    106         c += inverseLength.Length;
    107110      }
    108111      if (p.Length != c) throw new ArgumentException("The length of the parameter vector does not match the number of free parameters for CovarianceRationalQuadraticArd", "p");
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs

    r8982 r9108  
    8484      int c = 0;
    8585      // gather parameter values
     86      if (InverseLengthParameter.Value != null) {
     87        inverseLength = InverseLengthParameter.Value.Value;
     88      } else {
     89        inverseLength = 1.0 / Math.Exp(p[c]);
     90        c++;
     91      }
    8692      if (ScaleParameter.Value != null) {
    8793        scale = ScaleParameter.Value.Value;
     
    94100      } else {
    95101        shape = Math.Exp(p[c]);
    96         c++;
    97       }
    98       if (InverseLengthParameter.Value != null) {
    99         inverseLength = InverseLengthParameter.Value.Value;
    100       } else {
    101         inverseLength = 1.0 / Math.Exp(p[c]);
    102102        c++;
    103103      }
  • 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    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceSquaredExponentialIso.cs

    r8982 r9108  
    116116    }
    117117
     118    // order of returned gradients must match the order in GetParameterValues!
    118119    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, double sf2, double inverseLength, IEnumerable<int> columnIndices) {
    119120      double d = i == j
Note: See TracChangeset for help on using the changeset viewer.