Last change
on this file since 17189 was
15771,
checked in by bburlacu, 7 years ago
|
#2895: Add solution skeleton for PushGP with genealogy analysis.
|
File size:
893 bytes
|
Line | |
---|
1 | using System;
|
---|
2 |
|
---|
3 | namespace HeuristicLab.Problems.ProgramSynthesis { |
---|
4 | using HeuristicLab.Core;
|
---|
5 |
|
---|
6 | public static class RandomExtensions {
|
---|
7 | /// <summary>
|
---|
8 | /// Generates a random biased towards min
|
---|
9 | /// <see href="https://gamedev.stackexchange.com/questions/116832/random-number-in-a-range-biased-toward-the-low-end-of-the-range">Source</see>
|
---|
10 | /// </summary>
|
---|
11 | /// <param name="min">Minimum random int</param>
|
---|
12 | /// <param name="max">Maximum random int</param>
|
---|
13 | /// <param name="biasLevel">The bigger this values is, the bigger is the probability that min will be generated</param>
|
---|
14 | /// <param name="random">Random number generater</param>
|
---|
15 | /// <returns></returns>
|
---|
16 | public static int NextBiased(this IRandom random, int min, int max, double biasLevel) {
|
---|
17 | return (int)(min + (max - min) * Math.Pow(random.NextDouble(), biasLevel));
|
---|
18 | }
|
---|
19 | }
|
---|
20 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.