Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 8678

Ignore:
Timestamp:
09/21/12 18:45:15 (12 years ago)
Message:

Location:
trunk/sources
Files:
16 edited

Unmodified
Removed
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis.Views/3.4/GaussianProcessRegressionSolutionLineChartView.cs

 r8580 namespace HeuristicLab.Algorithms.DataAnalysis.Views { [View("Line Chart 2")] [View("Line Chart (95% confidence interval)")] [Content(typeof(GaussianProcessRegressionSolution))] public partial class GaussianProcessRegressionSolutionLineChartView : DataAnalysisSolutionEvaluationView {
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceConst.cs

 r8612 } public double GetCovariance(double[,] x, int i, int j) { public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { return scale; } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { yield return 2.0 * scale; } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return scale; }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinear.cs

 r8612 } public double GetCovariance(double[,] x, int i, int j) { return Util.ScalarProd(x, i, j); public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { return Util.ScalarProd(x, i, j, 1, columnIndices); } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { yield break; } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return Util.ScalarProd(x, i, xt, j); }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceLinearArd.cs

 r8612 } public double GetCovariance(double[,] x, int i, int j) { return Util.ScalarProd(x, i, j, inverseLength); public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { return Util.ScalarProd(x, i, j, inverseLength, columnIndices); } public IEnumerable GetGradient(double[,] x, int i, int j) { for (int k = 0; k < inverseLength.Length; k++) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); foreach (int k in columnIndices) { yield return -2.0 * x[i, k] * x[j, k] * inverseLength[k] * inverseLength[k]; } } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { return Util.ScalarProd(x, i, xt, j, inverseLength); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return Util.ScalarProd(x, i, xt, j, inverseLength, columnIndices); } }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceMaternIso.cs

 r8612 } public double GetCovariance(double[,] x, int i, int j) { public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { double dist = i == j ? 0.0 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength)); : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices)); return sf2 * m(dist); } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { double dist = i == j ? 0.0 : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength)); : Math.Sqrt(Util.SqrDist(x, i, j, Math.Sqrt(d) * inverseLength, columnIndices)); yield return sf2 * dm(dist); } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { double dist = Math.Sqrt(Util.SqrDist(x, i, xt, j, Math.Sqrt(d) * inverseLength)); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { double dist = Math.Sqrt(Util.SqrDist(x, i, xt, j, Math.Sqrt(d) * inverseLength, columnIndices)); return sf2 * m(dist); }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceNoise.cs

 r8612 } public double GetCovariance(double[,] x, int i, int j) { public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { return sf2; } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { yield return 2 * sf2; } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return 0.0; }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovariancePeriodic.cs

 r8612 Name = ItemName; Description = ItemDescription; scaleParameter = new HyperParameter("Scale", "The scale of the periodic covariance function."); inverseLengthParameter = new HyperParameter("InverseLength", "The inverse length parameter for the periodic covariance function."); } public double GetCovariance(double[,] x, int i, int j) { double k = i == j ? 0.0 : GetDistance(x, x, i, j); public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { if (columnIndices == null || columnIndices.Count() != 1) throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); double k = i == j ? 0.0 : GetDistance(x, x, i, j, columnIndices); k = Math.PI * k / period; k = Math.Sin(k) * inverseLength; } public IEnumerable GetGradient(double[,] x, int i, int j) { double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j) / period; public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { if (columnIndices == null || columnIndices.Count() != 1) throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); double v = i == j ? 0.0 : Math.PI * GetDistance(x, x, i, j, columnIndices) / period; double gradient = Math.Sin(v) * inverseLength; gradient *= gradient; } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { double k = GetDistance(x, xt, i, j); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { if (columnIndices == null || columnIndices.Count() != 1) throw new ArgumentException("The periodic covariance function can only be used for one dimension.", "columnIndices"); double k = GetDistance(x, xt, i, j, columnIndices); k = Math.PI * k / period; k = Math.Sin(k) * inverseLength; } private double GetDistance(double[,] x, double[,] xt, int i, int j) { return Math.Sqrt(Util.SqrDist(x, i, xt, j)); private double GetDistance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return Math.Sqrt(Util.SqrDist(x, i, xt, j, 1, columnIndices)); } }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceProduct.cs

 r8620 } public double GetCovariance(double[,] x, int i, int j) { return factors.Select(f => f.GetCovariance(x, i, j)).Aggregate((a, b) => a * b); public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { return factors.Select(f => f.GetCovariance(x, i, j, columnIndices)).Aggregate((a, b) => a * b); } public IEnumerable GetGradient(double[,] x, int i, int j) { var covariances = factors.Select(f => f.GetCovariance(x, i, j)).ToArray(); public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { var covariances = factors.Select(f => f.GetCovariance(x, i, j, columnIndices)).ToArray(); for (int ii = 0; ii < factors.Count; ii++) { foreach (var g in factors[ii].GetGradient(x, i, j)) { foreach (var g in factors[ii].GetGradient(x, i, j, columnIndices)) { double res = g; for (int jj = 0; jj < covariances.Length; jj++) } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { return factors.Select(f => f.GetCrossCovariance(x, xt, i, j)).Aggregate((a, b) => a * b); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return factors.Select(f => f.GetCrossCovariance(x, xt, i, j, columnIndices)).Aggregate((a, b) => a * b); } }

 r8615 public double GetCovariance(double[,] x, int i, int j) { public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); double b = 1 + 0.5 * d / shape; for (int k = 0; k < inverseLength.Length; k++) { } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { double d = Util.SqrDist(x, i, xt, j, inverseLength); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); }

 r8615 public double GetCovariance(double[,] x, int i, int j) { public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); double b = 1 + 0.5 * d / shape; } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { double d = Util.SqrDist(x, i, xt, j, inverseLength); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); return sf2 * Math.Pow(1 + 0.5 * d / shape, -shape); }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceScale.cs

 r8620 this.scaleParameter = new HyperParameter("Scale", "The scale parameter."); this.covParameter = new ValueParameter("CovarianceFunction", "The covariance function that should be scaled.", new CovarianceSquaredExponentialIso()); cov = covParameter.Value; Parameters.Add(this.scaleParameter); } public double GetCovariance(double[,] x, int i, int j) { return sf2 * cov.GetCovariance(x, i, j); public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { return sf2 * cov.GetCovariance(x, i, j, columnIndices); } public IEnumerable GetGradient(double[,] x, int i, int j) { yield return 2 * sf2 * cov.GetCovariance(x, i, j); foreach (var g in cov.GetGradient(x, i, j)) public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { yield return 2 * sf2 * cov.GetCovariance(x, i, j, columnIndices); foreach (var g in cov.GetGradient(x, i, j, columnIndices)) yield return sf2 * g; } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { return sf2 * cov.GetCrossCovariance(x, xt, i, j); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return sf2 * cov.GetCrossCovariance(x, xt, i, j, columnIndices); } }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSquaredExponentialArd.cs

 r8615 } public double GetCovariance(double[,] x, int i, int j) { public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); return sf2 * Math.Exp(-d / 2.0); } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); for (int ii = 0; ii < inverseLength.Length; ii++) { } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { double d = Util.SqrDist(x, i, xt, j, inverseLength); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); return sf2 * Math.Exp(-d / 2.0); }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSquaredExponentialIso.cs

 r8615 public double GetCovariance(double[,] x, int i, int j) { public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); return sf2 * Math.Exp(-d / 2.0); } public IEnumerable GetGradient(double[,] x, int i, int j) { public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { double d = i == j ? 0.0 : Util.SqrDist(x, i, j, inverseLength); : Util.SqrDist(x, i, j, inverseLength, columnIndices); double g = Math.Exp(-d / 2.0); yield return sf2 * g * d; } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { double d = Util.SqrDist(x, i, xt, j, inverseLength); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { double d = Util.SqrDist(x, i, xt, j, inverseLength, columnIndices); return sf2 * Math.Exp(-d / 2.0); }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceSum.cs

 r8612 } public double GetCovariance(double[,] x, int i, int j) { return terms.Select(t => t.GetCovariance(x, i, j)).Sum(); public double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices) { return terms.Select(t => t.GetCovariance(x, i, j, columnIndices)).Sum(); } public IEnumerable GetGradient(double[,] x, int i, int j) { return terms.Select(t => t.GetGradient(x, i, j)).Aggregate(Enumerable.Concat); public IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices) { return terms.Select(t => t.GetGradient(x, i, j, columnIndices)).Aggregate(Enumerable.Concat); } public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j) { return terms.Select(t => t.GetCrossCovariance(x, xt, i, j)).Sum(); public double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices) { return terms.Select(t => t.GetCrossCovariance(x, xt, i, j, columnIndices)).Sum(); } }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/ICovarianceFunction.cs

 r8562 int GetNumberOfParameters(int numberOfVariables); void SetParameter(double[] hyp); double GetCovariance(double[,] x, int i, int j); IEnumerable GetGradient(double[,] x, int i, int j); double GetCrossCovariance(double[,] x, double[,] xt, int i, int j); double GetCovariance(double[,] x, int i, int j, IEnumerable columnIndices = null); IEnumerable GetGradient(double[,] x, int i, int j, IEnumerable columnIndices = null); double GetCrossCovariance(double[,] x, double[,] xt, int i, int j, IEnumerable columnIndices = null); } }
• ## trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/Util.cs

 r8612 } public static double SqrDist(double[,] x, int i, int j, double scale = 1.0) { return SqrDist(x, i, x, j, scale); public static double SqrDist(double[,] x, int i, int j, double scale = 1.0, IEnumerable columnIndices = null) { return SqrDist(x, i, x, j, scale, columnIndices); } public static double SqrDist(double[,] x, int i, double[,] xt, int j, double scale = 1.0) { public static double SqrDist(double[,] x, int i, double[,] xt, int j, double scale = 1.0, IEnumerable columnIndices = null) { double ss = 0.0; for (int k = 0; k < x.GetLength(1); k++) { if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); foreach (int k in columnIndices) { double d = x[i, k] - xt[j, k]; ss += d * d; } public static double SqrDist(double[,] x, int i, int j, double[] scale) { public static double SqrDist(double[,] x, int i, int j, double[] scale, IEnumerable columnIndices = null) { return SqrDist(x, i, x, j, scale); } public static double SqrDist(double[,] x, int i, double[,] xt, int j, double[] scale) { public static double SqrDist(double[,] x, int i, double[,] xt, int j, double[] scale, IEnumerable columnIndices = null) { double ss = 0.0; for (int k = 0; k < x.GetLength(1); k++) { if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); foreach (int k in columnIndices) { double d = x[i, k] - xt[j, k]; ss += d * d * scale[k] * scale[k]; return ss; } public static double ScalarProd(double[,] x, int i, int j, double scale = 1.0) { return ScalarProd(x, i, x, j, scale); public static double ScalarProd(double[,] x, int i, int j, double scale = 1.0, IEnumerable columnIndices = null) { return ScalarProd(x, i, x, j, scale, columnIndices); } public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double scale = 1.0) { public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double scale = 1.0, IEnumerable columnIndices = null) { double sum = 0.0; for (int k = 0; k < x.GetLength(1); k++) { if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); foreach (int k in columnIndices) { sum += x[i, k] * xt[j, k]; } return scale * scale * sum; } public static double ScalarProd(double[,] x, int i, int j, double[] scale) { return ScalarProd(x, i, x, j, scale); public static double ScalarProd(double[,] x, int i, int j, double[] scale, IEnumerable columnIndices = null) { return ScalarProd(x, i, x, j, scale, columnIndices); } public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double[] scale) { public static double ScalarProd(double[,] x, int i, double[,] xt, int j, double[] scale, IEnumerable columnIndices = null) { double sum = 0.0; for (int k = 0; k < x.GetLength(1); k++) { if (columnIndices == null) columnIndices = Enumerable.Range(0, x.GetLength(1)); foreach (int k in columnIndices) { sum += x[i, k] * scale[k] * xt[j, k] * scale[k]; }
Note: See TracChangeset for help on using the changeset viewer.