#region License Information
/* HeuristicLab
* Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Problems.DataAnalysis {
[Item("Exponential", "Exponential transformation x' = Base ^ x")]
[StorableClass]
public class ExponentialTransformation : Transformation {
#region Parameters
private FixedValueParameter BaseParameter {
get { return (FixedValueParameter)Parameters["Base"]; }
}
#endregion
#region Properties
public double Base {
get { return BaseParameter.Value.Value; }
set { BaseParameter.Value.Value = value; }
}
#endregion
#region Constructor, Cloning & Persistence
public ExponentialTransformation()
: base() {
Parameters.Add(new FixedValueParameter("Base", "", new DoubleValue(Math.E)));
}
protected ExponentialTransformation(ExponentialTransformation original, Cloner cloner)
: base(original, cloner) {
}
public override IDeepCloneable Clone(Cloner cloner) {
return new ExponentialTransformation(this, cloner);
}
[StorableConstructor]
protected ExponentialTransformation(bool deserializing)
: base(deserializing) {
}
#endregion
public override IEnumerable Apply(IEnumerable data) {
return Apply(data, Base);
}
public override IEnumerable InverseApply(IEnumerable data) {
return InverseApply(data, Base);
}
public static IEnumerable Apply(IEnumerable data, double @base = Math.E) {
return data.Select(x => Math.Pow(@base, x));
}
public static IEnumerable InverseApply(IEnumerable data, double @base = Math.E) {
return LogarithmTransformation.Apply(data, @base);
}
}
}