Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/08/13 21:54:55 (12 years ago)
Author:
gkronber
Message:

#1902 reformulated calculation of periodic covariance function

File:
1 edited

Legend:

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

    r9108 r9211  
    134134
    135135    private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double period, double inverseLength) {
    136       double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period;
    137       double gradient = Math.Sin(v) * inverseLength;
     136      double k = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period;
     137      double gradient = Math.Sin(k) * inverseLength;
    138138      gradient *= gradient;
    139139      yield return 4.0 * scale * Math.Exp(-2.0 * gradient) * gradient;
    140       double r = Math.Sin(v) * inverseLength;
    141       yield return 4.0 * scale * inverseLength * Math.Exp(-2 * r * r) * r * Math.Cos(v) * v;
    142       yield return 2.0 * scale * Math.Exp(-2 * gradient);
     140      double r = Math.Sin(k) * inverseLength;
     141      yield return 2.0 * k * scale * Math.Exp(-2 * r * r) *Math.Sin(2*k) * inverseLength * inverseLength;
     142      yield return 2.0 * scale * Math.Exp(-2 * gradient);
     143      /*
     144       *  double s = Math.Log(scale) / 2.0;
     145      double l = Math.Log(1.0 / inverseLength);
     146      double p = Math.Log(period);
     147
     148      double v;
     149      {
     150        v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) * Math.Exp(-p);
     151        double sin = Math.Sin(v);
     152        double sin2 = sin * sin;
     153        yield return 4.0 * sin2 * Math.Exp(-2.0 * Math.Exp(-2 * l) * sin2 - 2 * l + 2 * s);
     154      }
     155      {
     156        double pi_d = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices);
     157        double sin = Math.Sin(Math.Exp(-p)*pi_d);
     158        double sin2 = Math.Sin(2*Math.Exp(-p)*pi_d);
     159        yield return 2*pi_d*sin2*Math.Exp(-2*Math.Exp(-2*l)*sin*sin - 2*l - p + 2*s);
     160      }
     161      {
     162        double pi_d = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices);
     163        double sin = Math.Sin(Math.Exp(-p) * pi_d);
     164        yield return 2 * Math.Exp(2 * scale - 2 * Math.Exp(-2 * l) * sin * sin);
     165      }*/
    143166    }
    144167
Note: See TracChangeset for help on using the changeset viewer.