- Timestamp:
- 07/20/10 21:46:03 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionEvaluator.cs
r4038 r4056 141 141 142 142 143 //algorithm taken from progamming pearls page 127144 //IMPORTANT because IEnumerables with yield are used the seed must best be specified to return always145 //the same sequence of numbers without caching the values.146 143 private static IEnumerable<int> GenerateRowsToEvaluate(uint seed, double relativeAmount, int start, int end) { 147 144 if (end < start) throw new ArgumentException("Start value is larger than end value."); 148 145 int count = (int)((end - start) * relativeAmount); 149 146 if (count == 0) count = 1; 150 151 int remaining = end - start; 152 MersenneTwister random = new MersenneTwister(seed); 153 for (int i = start; i < end && count > 0; i++) { 154 double probabilty = random.NextDouble(); 155 if (probabilty < ((double)count) / remaining) { 156 count--; 157 yield return i; 158 } 159 remaining--; 160 } 147 return RandomEnumerable.SampleRandomNumbers(seed, start, end, count); 161 148 } 162 149
Note: See TracChangeset
for help on using the changeset viewer.