Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/27/21 13:30:00 (3 years ago)
Author:
chaider
Message:

#3075 noise generation method to ValueGenerator; use same method for generating noise in friedman and feynman instances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/ValueGenerator.cs

    r17180 r18032  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     25using HeuristicLab.Common;
     26using HeuristicLab.Core;
    2427using HeuristicLab.Random;
    2528
     
    97100      }
    98101    }
     102
     103    public static List<double> GenerateNoise(IEnumerable<double> target, IRandom rand, double? noiseRatio) {
     104      if (noiseRatio == null) return null;
     105
     106      var targetNoise = new List<double>();
     107      var targetSigma = target.StandardDeviation();
     108      var noisePrng = new NormalDistributedRandomPolar(rand, 0, targetSigma * Math.Sqrt(noiseRatio.Value / (1.0 - noiseRatio.Value)));
     109
     110      targetNoise.AddRange(target.Select(t => t + noisePrng.NextDouble()).ToList());
     111      return targetNoise;
     112    }
    99113  }
    100114}
Note: See TracChangeset for help on using the changeset viewer.