Changeset 15938 for branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmTransformation.cs
- Timestamp:
- 05/17/18 10:03:01 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2906_Transformations/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Transformations/LogarithmTransformation.cs
r15865 r15938 37 37 get { return (FixedValueParameter<DoubleValue>)Parameters["Base"]; } 38 38 } 39 private FixedValueParameter<DoubleValue> OffsetParameter { 40 get { return (FixedValueParameter<DoubleValue>)Parameters["Offset"]; } 41 } 39 42 #endregion 40 43 … … 44 47 set { BaseParameter.Value.Value = value; } 45 48 } 49 public double Offset { 50 get { return OffsetParameter.Value.Value; } 51 set { OffsetParameter.Value.Value = value; } 52 } 46 53 #endregion 47 54 … … 50 57 : base() { 51 58 Parameters.Add(new FixedValueParameter<DoubleValue>("Base", "Base the logarithm", new DoubleValue(Math.E))); 59 Parameters.Add(new FixedValueParameter<DoubleValue>("Offset", "Offset before the logarithm", new DoubleValue(0.0))); 52 60 } 53 61 … … 66 74 67 75 public override bool Check(IEnumerable<double> data, out string errorMessage) { 68 if (data.Any(x => x <= 0)) {76 if (data.Any(x => x + Offset <= 0)) { 69 77 errorMessage = "Log is not available for zero or negative values"; 70 78 return false; … … 74 82 75 83 public override IEnumerable<double> Apply(IEnumerable<double> data) { 76 return Apply(data, Base );84 return Apply(data, Base, Offset); 77 85 } 78 86 79 87 public override IEnumerable<double> InverseApply(IEnumerable<double> data) { 80 return InverseApply(data, Base );88 return InverseApply(data, Base, Offset); 81 89 } 82 90 83 91 84 public static IEnumerable<double> Apply(IEnumerable<double> data, double @base = Math.E ) {85 return data.Select(x => Math.Log(x , @base));92 public static IEnumerable<double> Apply(IEnumerable<double> data, double @base = Math.E, double offset = 0.0) { 93 return data.Select(x => Math.Log(x + offset, @base)); 86 94 } 87 95 88 public static IEnumerable<double> InverseApply(IEnumerable<double> data, double @base = Math.E ) {89 return ExponentialTransformation. Apply(data, @base);96 public static IEnumerable<double> InverseApply(IEnumerable<double> data, double @base = Math.E, double offset = 0.0) { 97 return ExponentialTransformation.InverseApply(data, @base).Select(x => x - offset); 90 98 } 91 99 }
Note: See TracChangeset
for help on using the changeset viewer.