Пример #1
0
        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]++;
            }
        }
Пример #2
0
 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);
 }
Пример #3
0
 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);
 }
Пример #4
0
 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);
 }