public static void DataAsync(RndBase rnd, double min, double max, int sections, Action <int[]> updateAction, Func <bool> cancelAction) { int[] data = new int[sections]; double df = sections / (max - min); Stopwatch sw = new Stopwatch(); sw.Start(); while (true) { double val; do { val = rnd.Next(); if (!cancelAction()) { return; } }while (val < min || val > max); if (sw.Elapsed.Milliseconds > 100) { updateAction(data); sw.Restart(); } int section = (int)((val - min) * df); data[section]++; } }
public RndSum2(Distribution t) : base(t) { _a = new RndA(t); _b = new RndB2_2(t); _c = new RndC2(t); _sg1 = t.Beta; _sg2 = _sg1 + IntG_B(-1); _unif = new UniformContinuousDistribution(0, 1); }
public RndSum(Distribution t) : base(t) { _a = new RndA(t); _b = new RndB(t); _c = new RndC(t); _p2 = 1 - (1 - t.Beta) / Math.E - t.Bn * t.AlphaRev / Math.E; //t.Beta + (Math.E - 1) * (1 - t.Beta) / Math.E - t.Bn * t.AlphaRev / Math.E; _unif = new UniformContinuousDistribution(0, 1); }
public static int[] Data(RndBase rnd, int n, double min, double max, int sections = 250) { int[] data = new int[sections]; for (int i = 0; i < n; i++) { double val; do { val = rnd.Next(); }while (val < min || val > max); int section = (int)((val - min) / (max - min) * sections); data[section]++; } return(data); }