Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/19/21 16:07:45 (3 years ago)
Author:
mkommend
Message:

#2521: Merged trunk changes into branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/ValueGenerator.cs

    r17226 r18086  
    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.