Ejemplo n.º 1
0
        public void NextDouble()
        {
            Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            var rnd = new MT19937(123456);

            var actual = new double[100];

            for (var i = 0; i < 100; ++i)
            {
                actual[i] = Math.Round(rnd.NextDouble(), 6);
            }

            Assert.Equal(new double[]
            {
                0.898029, 0.654526, 0.304360, 0.724096, 0.692163, 0.762186, 0.017384, 0.863317, 0.440578, 0.327692,
                0.157624, 0.194010, 0.487429, 0.230038, 0.440785, 0.810590, 0.563060, 0.092952, 0.530282, 0.854167,
                0.228575, 0.763807, 0.606799, 0.026897, 0.658474, 0.866361, 0.106265, 0.446750, 0.367851, 0.505000,
                0.869097, 0.519178, 0.874243, 0.163699, 0.186622, 0.550845, 0.189079, 0.020268, 0.916089, 0.573960,
                0.414645, 0.906261, 0.182299, 0.434931, 0.633394, 0.905933, 0.324769, 0.126503, 0.917170, 0.493531,
                0.426479, 0.942722, 0.269054, 0.948500, 0.972566, 0.371763, 0.840350, 0.962808, 0.052126, 0.302453,
                0.736815, 0.691647, 0.519616, 0.720329, 0.804298, 0.270261, 0.979788, 0.118823, 0.864857, 0.918150,
                0.335647, 0.970717, 0.268570, 0.182163, 0.296486, 0.638157, 0.901131, 0.651100, 0.886426, 0.379444,
                0.853851, 0.601951, 0.085475, 0.255315, 0.017430, 0.312999, 0.032936, 0.095106, 0.816612, 0.373813,
                0.143905, 0.007874, 0.419690, 0.280102, 0.348921, 0.098547, 0.719365, 0.117563, 0.938149, 0.935187,
            }, actual);

            rnd.Init(951753);

            for (var i = 0; i < 100; ++i)
            {
                actual[i] = Math.Round(rnd.NextDouble(), 6);
            }

            Assert.Equal(new double[]
            {
                0.164258, 0.362222, 0.476577, 0.368516, 0.270835, 0.938640, 0.482388, 0.033788, 0.581499, 0.483967,
                0.112844, 0.315118, 0.693525, 0.593817, 0.122376, 0.352409, 0.139571, 0.435325, 0.156437, 0.434273,
                0.309665, 0.963321, 0.210233, 0.695153, 0.893191, 0.226208, 0.888139, 0.983691, 0.347230, 0.628064,
                0.825325, 0.904256, 0.953110, 0.734535, 0.170423, 0.334555, 0.841246, 0.730140, 0.788088, 0.000813,
                0.502416, 0.320501, 0.187989, 0.802559, 0.326378, 0.886604, 0.421912, 0.258907, 0.771110, 0.266313,
                0.188474, 0.865032, 0.830199, 0.735948, 0.045387, 0.608558, 0.266344, 0.878086, 0.296003, 0.954960,
                0.840953, 0.834262, 0.784732, 0.560700, 0.337408, 0.438021, 0.205282, 0.390405, 0.395393, 0.895767,
                0.176438, 0.163167, 0.182486, 0.870010, 0.591199, 0.131195, 0.742142, 0.799884, 0.432466, 0.359904,
                0.641052, 0.527554, 0.406604, 0.792959, 0.908348, 0.594474, 0.939199, 0.123638, 0.804795, 0.720115,
                0.345518, 0.909825, 0.518950, 0.429536, 0.059868, 0.943975, 0.283047, 0.918471, 0.280611, 0.982255,
            }, actual);
        }