Changeset 7759 for branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ValueGenerator.cs
- Timestamp:
- 04/24/12 16:37:40 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ValueGenerator.cs
r7698 r7759 26 26 using HeuristicLab.Random; 27 27 namespace HeuristicLab.Problems.Instances.Regression { 28 public class ValueGenerator {29 pr otectedstatic FastRandom rand = new FastRandom();28 public static class ValueGenerator { 29 private static FastRandom rand = new FastRandom(); 30 30 31 31 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; 34 35 } 35 36 36 37 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; 42 40 } 43 41 44 42 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); 50 45 } 51 46
Note: See TracChangeset
for help on using the changeset viewer.