コード例 #1
0
        public void NullRandomNumberGenerator()
        {
            var normal = new Normal(0.0, 1.0);
            var ms     = new MetropolisHastingsSampler <double>(0.2, normal.Density, (x, y) => (new Normal(x, 0.1)).Density(y), x => Normal.Sample(new Random(), x, 0.1), 10);

            Assert.Throws <ArgumentNullException>(() => ms.RandomSource = null);
        }
コード例 #2
0
 public void NullRandomNumberGenerator()
 {
     var random = MersenneTwister.Default;
     var normal = new Normal(0.0, 1.0, random);
     var ms = new MetropolisHastingsSampler<double>(0.2, normal.Density, (x, y) => Normal.PDF(x, 0.1, y), x => Normal.Sample(random, x, 0.1), 10);
     Assert.That(() => ms.RandomSource = null, Throws.TypeOf<ArgumentNullException>());
 }
コード例 #3
0
        public void NullRandomNumberGenerator()
        {
            var normal = new Normal(0.0, 1.0);
            var ms     = new MetropolisHastingsSampler <double>(0.2, normal.Density, (x, y) => (new Normal(x, 0.1)).Density(y),
                                                                x => Normal.Sample(new System.Random(), x, 0.1), 10);

            ms.RandomSource = null;
        }
        public void NullRandomNumberGenerator()
        {
            var random = MersenneTwister.Default;
            var normal = new Normal(0.0, 1.0, random);
            var ms     = new MetropolisHastingsSampler <double>(0.2, normal.Density, (x, y) => Normal.PDF(x, 0.1, y), x => Normal.Sample(random, x, 0.1), 10);

            Assert.That(() => ms.RandomSource = null, Throws.TypeOf <ArgumentNullException>());
        }
コード例 #5
0
        public void SampleArrayTest()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd    = new MersenneTwister();

            var ms = new MetropolisHastingsSampler <double>(0.2, normal.Density, (x, y) => (new Normal(x, 0.1)).Density(y), x => Normal.Sample(rnd, x, 0.1), 10)
            {
                RandomSource = rnd
            };

            ms.Sample(5);
        }
コード例 #6
0
        public void SampleArrayTest()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd    = new SystemRandomSource(1);

            var ms = new MetropolisHastingsSampler <double>(0.2, normal.Density, (x, y) => Normal.PDF(x, 0.1, y), x => Normal.Sample(rnd, x, 0.1), 10)
            {
                RandomSource = rnd
            };

            ms.Sample(5);
        }
コード例 #7
0
        public void SampleTest()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd = new MersenneTwister();

            var ms = new MetropolisHastingsSampler<double>(0.2, normal.Density, (x, y) => (new Normal(x, 0.1)).Density(y), x => Normal.Sample(rnd, x, 0.1), 10)
                     {
                         RandomSource = rnd
                     };

            ms.Sample();
        }
コード例 #8
0
        public void SampleTest()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd = new SystemRandomSource(1);

            var ms = new MetropolisHastingsSampler<double>(0.2, normal.Density, (x, y) => Normal.PDF(x, 0.1, y), x => Normal.Sample(rnd, x, 0.1), 10)
                {
                    RandomSource = rnd
                };

            ms.Sample();
        }
コード例 #9
0
        public void MetropolisHastingsConstructor()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd    = new MersenneTwister();

            var ms = new MetropolisHastingsSampler <double>(0.2, normal.Density, (x, y) => (new Normal(x, 0.1)).Density(y),
                                                            x => Normal.Sample(rnd, x, 0.1), 10);

            ms.RandomSource = rnd;
            Assert.IsNotNull(ms.RandomSource);

            ms.RandomSource = new System.Random();
            Assert.IsNotNull(ms.RandomSource);
        }
コード例 #10
0
        public void MetropolisHastingsConstructor()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd = new MersenneTwister();

            var ms = new MetropolisHastingsSampler<double>(0.2, normal.Density, (x, y) => (new Normal(x, 0.1)).Density(y), x => Normal.Sample(rnd, x, 0.1), 10)
                     {
                         RandomSource = rnd
                     };
            Assert.IsNotNull(ms.RandomSource);

            ms.RandomSource = new Random();
            Assert.IsNotNull(ms.RandomSource);
        }
コード例 #11
0
        public void MetropolisHastingsConstructor()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd = new SystemRandomSource(1);

            var ms = new MetropolisHastingsSampler<double>(0.2, normal.Density, (x, y) => Normal.PDF(x, 0.1, y), x => Normal.Sample(rnd, x, 0.1), 10)
                {
                    RandomSource = rnd
                };
            Assert.IsNotNull(ms.RandomSource);

            ms.RandomSource = new System.Random(0);
            Assert.IsNotNull(ms.RandomSource);
        }
コード例 #12
0
        public void MetropolisHastingsConstructor()
        {
            var normal = new Normal(0.0, 1.0);
            var rnd    = new SystemRandomSource(1);

            var ms = new MetropolisHastingsSampler <double>(0.2, normal.Density, (x, y) => Normal.PDF(x, 0.1, y), x => Normal.Sample(rnd, x, 0.1), 10)
            {
                RandomSource = rnd
            };

            Assert.IsNotNull(ms.RandomSource);

            ms.RandomSource = new System.Random(0);
            Assert.IsNotNull(ms.RandomSource);
        }
コード例 #13
0
 public void NullRandomNumberGenerator()
 {
     var normal = new Normal(0.0, 1.0);
     var ms = new MetropolisHastingsSampler<double>(0.2, normal.Density, (x, y) => (new Normal(x, 0.1)).Density(y), x => Normal.Sample(new Random(), x, 0.1), 10);
     Assert.Throws<ArgumentNullException>(() => ms.RandomSource = null);
 }