Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8439


Ignore:
Timestamp:
08/08/12 17:52:27 (12 years ago)
Author:
gkronber
Message:

#1902 implemented unit tests for mean and covariance functions. implemented sum and product mean function. fixed incorrect gradient calculation in covprod

Location:
trunk/sources
Files:
4 added
3 edited

Legend:

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

    r8416 r8439  
    8787
    8888    public double[] GetGradient(int i, int j) {
    89       return factors.Select(t => t.GetGradient(i, j)).SelectMany(seq => seq).ToArray();
     89      return Enumerable.Range(0, GetNumberOfParameters(numberOfVariables)).Select(k => GetGradient(i, j, k)).ToArray();
     90    }
     91    public double GetGradient(int i, int j, int k) {
     92      // map from parameter index to factor
     93      var vi = factors.Select((f, idx) => Enumerable.Repeat(idx, f.GetNumberOfParameters(numberOfVariables))).SelectMany(x => x).ToArray();
     94      double res = 1.0;
     95      int jj = Enumerable.Range(0, k).Count(e => vi[e] == vi[k]);
     96      for (int ii = 0; ii < factors.Count; ii++) {
     97        var f = factors[ii];
     98        if (ii == vi[k]) {
     99          res *= f.GetGradient(i, j)[jj];
     100        } else {
     101          res *= f.GetCovariance(i, j);
     102        }
     103      }
     104      return res;
    90105    }
    91106  }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj

    r8419 r8439  
    120120    </Compile>
    121121    <Compile Include="FixedDataAnalysisAlgorithm.cs" />
     122    <Compile Include="GaussianProcess\MeanProd.cs" />
     123    <Compile Include="GaussianProcess\MeanSum.cs" />
    122124    <Compile Include="GaussianProcess\CovarianceProd.cs" />
    123125    <Compile Include="GaussianProcess\CovarianceSum.cs" />
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r8323 r8439  
    290290    <Compile Include="HeuristicLab-3.3\ThreadSafeLogTest.cs" />
    291291    <Compile Include="HeuristicLab-3.3\ToStringTest.cs" />
     292    <Compile Include="HeuristicLab.Algorithms.DataAnalysis-3.4\GaussianProcessFunctionsTest.cs" />
    292293    <Compile Include="HeuristicLab.Analysis-3.3\MultidimensionalScalingTest.cs" />
    293294    <Compile Include="HeuristicLab.Encodings.BinaryVectorEncoding-3.3\Auxiliary.cs" />
Note: See TracChangeset for help on using the changeset viewer.