public static List <double> RandomDoubles(int length) { Random r = BetterRandom.NewRandom(); var result = new List <double>(length); double multiplier = Math.Pow(10.0, Math.Floor(Math.Log10(length) + 1.0)); for (int i = 0; i < length; i++) { result.Add(Math.Floor(r.NextDouble() * multiplier)); } return(result); }
public static double RandomInDiscrete(List <double> probabilities) { double r = BetterRandom.NewRandom().NextDouble(); double sum = 0.0; double result; for (int i = 0; i < probabilities.Count; i++) { sum += probabilities[i]; if (sum >= r) { result = i; return(result); } } result = -1.0; return(result); }
public static int RandomInUniform(int a) { Random r = BetterRandom.NewRandom(); return((int)(r.NextDouble() * a)); }
public static double RandomInUniform(double a) { Random r = BetterRandom.NewRandom(); return(r.NextDouble() * a); }