Changeset 10530 for stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs
- Timestamp:
- 03/04/14 11:30:58 (11 years ago)
- Location:
- stable
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 10489-10491,10493
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Algorithms.DataAnalysis merged: 10489-10491,10493
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/CovarianceFunctions/CovarianceRationalQuadraticIso.cs
r9456 r10530 44 44 get { return (IValueParameter<DoubleValue>)Parameters["Shape"]; } 45 45 } 46 47 private bool HasFixedScaleParameter { 48 get { return ScaleParameter.Value != null; } 49 } 50 private bool HasFixedInverseLengthParameter { 51 get { return InverseLengthParameter.Value != null; } 52 } 53 private bool HasFixedShapeParameter { 54 get { return ShapeParameter.Value != null; } 55 } 56 57 46 58 [StorableConstructor] 47 59 private CovarianceRationalQuadraticIso(bool deserializing) … … 68 80 69 81 public int GetNumberOfParameters(int numberOfVariables) { 70 return ( ScaleParameter.Value != null? 0 : 1) +71 ( ShapeParameter.Value != null? 0 : 1) +72 ( InverseLengthParameter.Value != null? 0 : 1);82 return (HasFixedScaleParameter ? 0 : 1) + 83 (HasFixedShapeParameter ? 0 : 1) + 84 (HasFixedInverseLengthParameter ? 0 : 1); 73 85 } 74 86 … … 84 96 int c = 0; 85 97 // gather parameter values 86 if ( InverseLengthParameter.Value != null) {98 if (HasFixedInverseLengthParameter) { 87 99 inverseLength = InverseLengthParameter.Value.Value; 88 100 } else { … … 90 102 c++; 91 103 } 92 if ( ScaleParameter.Value != null) {104 if (HasFixedScaleParameter) { 93 105 scale = ScaleParameter.Value.Value; 94 106 } else { … … 96 108 c++; 97 109 } 98 if ( ShapeParameter.Value != null) {110 if (HasFixedShapeParameter) { 99 111 shape = ShapeParameter.Value.Value; 100 112 } else { … … 108 120 double scale, shape, inverseLength; 109 121 GetParameterValues(p, out scale, out shape, out inverseLength); 122 var fixedInverseLength = HasFixedInverseLengthParameter; 123 var fixedScale = HasFixedScaleParameter; 124 var fixedShape = HasFixedShapeParameter; 110 125 // create functions 111 126 var cov = new ParameterizedCovarianceFunction(); … … 120 135 return scale * Math.Pow(1 + 0.5 * d / shape, -shape); 121 136 }; 122 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength );137 cov.CovarianceGradient = (x, i, j) => GetGradient(x, i, j, columnIndices, scale, shape, inverseLength, fixedInverseLength, fixedScale, fixedShape); 123 138 return cov; 124 139 } 125 140 126 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength) { 141 private static IEnumerable<double> GetGradient(double[,] x, int i, int j, IEnumerable<int> columnIndices, double scale, double shape, double inverseLength, 142 bool fixedInverseLength, bool fixedScale, bool fixedShape) { 127 143 double d = i == j 128 144 ? 0.0 … … 130 146 131 147 double b = 1 + 0.5 * d / shape; 132 yield return scale * Math.Pow(b, -shape - 1) * d;133 yield return 2 * scale * Math.Pow(b, -shape);134 yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b));148 if (!fixedInverseLength) yield return scale * Math.Pow(b, -shape - 1) * d; 149 if (!fixedScale) yield return 2 * scale * Math.Pow(b, -shape); 150 if (!fixedShape) yield return scale * Math.Pow(b, -shape) * (0.5 * d / b - shape * Math.Log(b)); 135 151 } 136 152 }
Note: See TracChangeset
for help on using the changeset viewer.