Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UniformRealSampler"/> class.
 /// </summary>
 /// <param name="generator">
 /// The underlying bit generator to use.
 /// </param>
 /// <param name="min">
 /// The lower bound of the values that will be generated.
 /// </param>
 /// <param name="max">
 /// The upper bound of the values that will be generated.
 /// </param>
 /// <exception cref="ArgumentNullException">
 /// If <paramref name="generator"/> is null.
 /// </exception>
 /// <exception cref="ArgumentException">
 /// If <paramref name="min"/> is infinite or nan.
 /// If <paramref name="max"/> is infinite or nan.
 /// If <paramref name="min"/> is greater than or equal to <paramref name="max"/>.
 /// </exception>
 public UniformRealSampler(IRandomNumberEngine generator, double min, double max)
 {
     UniformRealDistribution.ValidateParameters(min, max);
     this.generator = generator ?? throw new ArgumentNullException(nameof(generator));
     this.Min       = min;
     this.Max       = max;
 }
Ejemplo n.º 2
0
        public void TestGetIntegrateDistribution(double x, double min, double max, double error)
        {
            var sampler = new UniformRealSampler(new ReducedThreeFry4X64(1), min, max);
            var referenceDistribution = new UniformRealDistribution(min, max);

            SamplerTester.TestIntegrateDistribution(x, sampler, referenceDistribution, error);
        }
Ejemplo n.º 3
0
        private static ArtaProcessUniform createArtaProcessU(UniformRealDistribution uniform, double[] artaCorrelationCoefficients, RandomGenerator random) //throws NotStationaryException
        {
            ArtaProcessUniform arta = null;
            int dim = artaCorrelationCoefficients.Length;

            double[] arCorrelationCoefficients = new double[dim];
            for (int i = 0; i < dim; i++)
            {
                arCorrelationCoefficients[i] = 2 * Math.Sin(Math.PI * artaCorrelationCoefficients[i] / 6);
            }
            ArProcess ar = ArProcessFactory.CreateArProcess(arCorrelationCoefficients, random);

            arta = new ArtaProcessUniform(ar, uniform.getSupportLowerBound(), uniform.getSupportUpperBound());
            return(arta);
        }
 public void TestInvalidQuantile(double min, double max, double probability)
 {
     Assert.Throws <ArgumentException>(
         () => _ = new UniformRealDistribution(min, max).Quantile(probability));
 }
 public void ConstructInvalid(double min, double max)
 {
     Assert.Throws <ArgumentException>(
         () => _ = new UniformRealDistribution(min, max));
 }
 public void TestCumulativeDistribution(double min, double max, double x, double expected)
 {
     IsClose(expected, new UniformRealDistribution(min, max).CumulativeDistribution(x));
     IsClose(expected, UniformRealDistribution.CumulativeDistributionFunction(x, min, max));
 }