Exemplo n.º 1
0
        /// <summary>
        /// Build linear samples.
        /// </summary>
        /// <param name="x">X sample values.</param>
        /// <param name="y">Y samples values.</param>
        /// <param name="xtest">X test values.</param>
        /// <param name="ytest">Y test values.</param>
        /// <param name="samples">Sample values.</param>
        /// <param name="sampleOffset">Sample offset.</param>
        /// <param name="slope">Slope number.</param>
        /// <param name="intercept">Intercept criteria.</param>
        public static void Build(out double[] x, out double[] y, out double[] xtest, out double[] ytest, int samples = 3, double sampleOffset = -0.5, double slope = 2.0, double intercept = -1.0)
        {
            // Fixed-seed "random" distribution to ensure we always test with the same data
            var uniform = new ContinuousUniformDistribution(0.0, 1.0, new Random(42));

            // build linear samples
            x = new double[samples];
            y = new double[samples];
            for (int i = 0; i < x.Length; i++)
            {
                x[i] = i + sampleOffset;
                y[i] = (x[i] * slope) + intercept;
            }
            // build linear test vectors randomly between the sample points
            xtest = new double[samples + 1];
            ytest = new double[samples + 1];
            if (samples == 1)
            {
                // y = const
                xtest[0] = sampleOffset - uniform.Sample();
                xtest[1] = sampleOffset + uniform.Sample();
                ytest[0] = ytest[1] = (sampleOffset * slope) + intercept;
            }
            else
            {
                for (int i = 0; i < xtest.Length; i++)
                {
                    xtest[i] = (i - 1) + sampleOffset + uniform.Sample();
                    ytest[i] = (xtest[i] * slope) + intercept;
                }
            }
        }
Exemplo n.º 2
0
        public int HabitiationParameter(HabitationParameterType habitationParameterType)
        {
            switch (habitationParameterType)
            {
            case HabitationParameterType.Gravity:
            case HabitationParameterType.Temperature:
                return((int)Math.Round(TrapezoidalDistribution.Sample(this.rng, -49.5, 49.5, -40, 40)));

            case HabitationParameterType.Radiation:
                return((int)Math.Round(ContinuousUniformDistribution.Sample(this.rng, -49.5, 49.5)));

            default:
                throw new ArgumentOutOfRangeException(nameof(habitationParameterType), habitationParameterType, null);
            }
        }