Пример #1
0
        NextDouble()
        {
            double randTheta = _uniformDistribution.NextDouble();
            double randW     = _exponentialDistribution.NextDouble();

            if (!Number.AlmostEqual(_exponent, 1))
            {
                double angle   = _exponent * (randTheta + _theta);
                double factor1 = Math.Sin(angle) / Math.Pow(Math.Cos(randTheta), (1.0 / _exponent));
                double factor2 = Math.Pow(Math.Cos(randTheta - angle) / randW, (1 - _exponent) / _exponent);
                return(_factor * factor1 * factor2);
            }

            double part1      = Constants.Pi_2 + (_skewness * randTheta);
            double summand    = part1 * Math.Tan(randTheta);
            double subtrahend = _skewness * Math.Log(Constants.Pi_2 * randW * Math.Cos(randTheta) / part1);

            return((2.0 / Math.PI) * (summand - subtrahend));
        }
        static void BuildLinearCase(int start, int stop, out double[] x, out double[] y, out double[] xtest, out double[] ytest)
        {
            const double yOffset = 2.0;
            int samples = stop - start + 1;
            ContinuousUniformDistribution uniform = new ContinuousUniformDistribution();

            // build linear samples
            x = new double[samples];
            y = new double[samples];
            for(int i = 0; i < x.Length; i++)
            {
                int z = start + i;
                x[i] = z;
                y[i] = z + yOffset; // arbitrary small y-axis offset
            }

            // build linear test vectors randomly between the sample points
            xtest = new double[samples+1];
            ytest = new double[samples+1];
            if(samples == 1)
            {
                xtest[0] = start - uniform.NextDouble();
                xtest[1] = start + uniform.NextDouble();
                ytest[0] = ytest[1] = start + yOffset;
            }
            else
            {
                for(int i = 0; i < xtest.Length; i++)
                {
                    double z = (i - 1) + uniform.NextDouble();
                    xtest[i] = z;
                    ytest[i] = z + yOffset;
                }
            }
        }