Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11313


Ignore:
Timestamp:
08/27/14 12:00:56 (10 years ago)
Author:
bburlacu
Message:

#2236: Added an overload of the GenerateSteps method accepting a Func<double,double> transform. Added GenerateLogarithmicSteps method for filling an interval with logarithmically spaced points.

File:
1 edited

Legend:

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

    r11171 r11313  
    4646        x += stepWidth;
    4747      }
     48    }
     49
     50    /// <summary>
     51    /// Generate a logarithmic sequence between start and end by applying a power-of-10 function to an underlying evenly spaced sequence
     52    /// </summary>
     53    /// <param name="start">The start of the sequence</param>
     54    /// <param name="end">The end of the sequence</param>
     55    /// <param name="stepWidth">The stepwidth for the original sequence before the points are transformed</param>
     56    /// <returns>A logarithmic sequence from start to end (inclusive)</returns>
     57    public static IEnumerable<double> GenerateLogarithmicSteps(double start, double end, double stepWidth) {
     58      return GenerateSteps(start, end, stepWidth, x => Math.Pow(10, x));
     59    }
     60
     61    /// <summary>
     62    /// Generates a sequence of points between start and end according to given transformation
     63    /// </summary>
     64    /// <param name="start">The smallest and first value of the sequence.</param>
     65    /// <param name="end">The largest and last value of the sequence.</param>
     66    /// <param name="stepWidth">The step size between subsequent values (before transform)</param>
     67    /// <param name="transform">The transform function</param>
     68    /// <returns></returns>
     69    public static IEnumerable<double> GenerateSteps(double start, double end, double stepWidth, Func<double, double> transform) {
     70      return GenerateSteps(start, end, stepWidth).Select(transform).Where(x => x < end || x.IsAlmost(end));
    4871    }
    4972
Note: See TracChangeset for help on using the changeset viewer.