[10784] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using HeuristicLab.Common;
|
---|
| 5 | using HeuristicLab.Core;
|
---|
| 6 | using HeuristicLab.Data;
|
---|
| 7 | using HeuristicLab.Parameters;
|
---|
| 8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 9 |
|
---|
| 10 | namespace HeuristicLab.Problems.DataAnalysis.Transformations {
|
---|
| 11 | [Item("DeviationTransformation", "Represents a linear Transformation using deviation Parameters")]
|
---|
| 12 | public class DeviationTransformation : LinearTransformation {
|
---|
| 13 | protected const string MeanParameterName = "Mean";
|
---|
| 14 | protected const string VarianceParameterName = "Variance";
|
---|
| 15 |
|
---|
| 16 | #region Parameters
|
---|
| 17 | public IValueParameter<DoubleValue> MeanParameter {
|
---|
| 18 | get { return (IValueParameter<DoubleValue>)Parameters[MeanParameterName]; }
|
---|
| 19 | }
|
---|
| 20 | public IValueParameter<DoubleValue> VarianceParameter {
|
---|
| 21 | get { return (IValueParameter<DoubleValue>)Parameters[VarianceParameterName]; }
|
---|
| 22 | }
|
---|
| 23 | #endregion
|
---|
| 24 |
|
---|
| 25 | #region properties
|
---|
| 26 | public double Mean {
|
---|
| 27 | get { return MeanParameter.Value.Value; }
|
---|
| 28 | }
|
---|
| 29 | public double Variance {
|
---|
| 30 | get { return VarianceParameter.Value.Value; }
|
---|
| 31 | }
|
---|
| 32 | #endregion
|
---|
| 33 |
|
---|
| 34 | [StorableConstructor]
|
---|
| 35 | protected DeviationTransformation(bool deserializing) : base(deserializing) { }
|
---|
| 36 | protected DeviationTransformation(Transformation<double> original, Cloner cloner)
|
---|
| 37 | : base(original, cloner) {
|
---|
| 38 | }
|
---|
| 39 | public DeviationTransformation(IEnumerable<string> allowedColumns)
|
---|
| 40 | : base(allowedColumns) {
|
---|
| 41 | MultiplierParameter.Hidden = true;
|
---|
| 42 | AddendParameter.Hidden = true;
|
---|
| 43 | Parameters.Add(new ValueParameter<DoubleValue>(MeanParameterName, "Mean value for the target deviation.", new DoubleValue(0.0)));
|
---|
| 44 | Parameters.Add(new ValueParameter<DoubleValue>(VarianceParameterName, "Variance for the target deviation.", new DoubleValue(1.0)));
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 48 | return new DeviationTransformation(this, cloner);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | public override IEnumerable<double> Apply(IEnumerable<double> data) {
|
---|
| 52 | ConfigureParameters(data);
|
---|
| 53 | return base.Apply(data);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | public override bool Check(IEnumerable<double> data, out string errorMsg) {
|
---|
| 57 | ConfigureParameters(data);
|
---|
| 58 | return base.Check(data, out errorMsg);
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | protected void ConfigureParameters(IEnumerable<double> data) {
|
---|
| 62 | double standardDeviation = data.StandardDeviation();
|
---|
| 63 | double middle = data.Average();
|
---|
| 64 | // TODO:
|
---|
| 65 | // http://en.wikipedia.org/wiki/Standard_deviation
|
---|
| 66 | // http://www.statistics4u.info/fundstat_germ/ee_ztransform.html
|
---|
| 67 | // https://www.uni-due.de/~bm0061/vorl12.pdf p5
|
---|
| 68 | throw new NotImplementedException();
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | }
|
---|
| 72 | }
|
---|