Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/24/12 16:37:40 (12 years ago)
Author:
sforsten
Message:

#1784:

  • deleted ClassificationData and RegressionData. RegressionProblemData and ClassificationProblemData are used instead
  • deleted not needed Transformer
  • ValueGenerator is now a static class and yield return is used return IEnumerable
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ValueGenerator.cs

    r7698 r7759  
    2626using HeuristicLab.Random;
    2727namespace HeuristicLab.Problems.Instances.Regression {
    28   public class ValueGenerator {
    29     protected static FastRandom rand = new FastRandom();
     28  public static class ValueGenerator {
     29    private static FastRandom rand = new FastRandom();
    3030
    3131    public static IEnumerable<double> GenerateSteps(double start, double end, double stepWidth) {
    32       return Enumerable.Range(0, (int)Math.Round(((end - start) / stepWidth) + 1))
    33                                       .Select(i => (start + i * stepWidth));
     32      int steps = (int)Math.Round(((end - start) / stepWidth) + 1);
     33      for (int i = 0; i < steps; i++)
     34        yield return start + i * stepWidth;
    3435    }
    3536
    3637    public static IEnumerable<double> GenerateUniformDistributedValues(int amount, double start, double end) {
    37       List<double> values = new List<double>();
    38       for (int i = 0; i < amount; i++) {
    39         values.Add(rand.NextDouble() * (end - start) + start);
    40       }
    41       return values;
     38      for (int i = 0; i < amount; i++)
     39        yield return rand.NextDouble() * (end - start) + start;
    4240    }
    4341
    4442    public static IEnumerable<double> GenerateNormalDistributedValues(int amount, double mu, double sigma) {
    45       List<double> values = new List<double>();
    46       for (int i = 0; i < amount; i++) {
    47         values.Add(NormalDistributedRandom.NextDouble(rand, mu, sigma));
    48       }
    49       return values;
     43      for (int i = 0; i < amount; i++)
     44        yield return NormalDistributedRandom.NextDouble(rand, mu, sigma);
    5045    }
    5146
Note: See TracChangeset for help on using the changeset viewer.