June 24 2002 12:31:03.084 PM HALTON_PRB A set of tests for HALTON. TEST01 HALTON_NUMBER computes the elements of a Halton sequence. Each call produces the next value. By default, the base is 2, and the sequence starts at element 1. In this test, we call HALTON_NUMBER several times. Element Halton 1 0.500000 2 0.250000 3 0.750000 4 0.125000 5 0.625000 6 0.375000 7 0.875000 8 0.625000E-01 9 0.562500 10 0.312500 TEST02 HALTON_NUMBER_SEQUENCE computes several elements of a Halton sequence on a single call. By default, the base is 2, and the sequence starts at element 1. In this test, we call HALTON_NUMBER_SEQUENCE once. Element Halton 1 0.500000 2 0.250000 3 0.750000 4 0.125000 5 0.625000 6 0.375000 7 0.875000 8 0.625000E-01 9 0.562500 10 0.312500 TEST03 HALTON_SEED_SET specifies the next element of the Halton sequence to compute. HALTON_SEED_GET reports the next element of the Halton sequence that will be computed. By default, the sequence starts at element 1. In this test, we demonstrate computing elements affects the seed, and how resetting the seed determines the next element computed. We start at element 1 and compute 10 elements. 1 0.500000 2 0.250000 3 0.750000 4 0.125000 5 0.625000 6 0.375000 7 0.875000 8 0.625000E-01 9 0.562500 10 0.312500 HALTON_SEED_GET reports current seed is 11 We jump back to element 6 and compute 10 elements. 6 0.375000 7 0.875000 8 0.625000E-01 9 0.562500 10 0.312500 11 0.812500 12 0.187500 13 0.687500 14 0.437500 15 0.937500 HALTON_SEED_GET reports current seed is 16 We restart at element 0 and compute 6 elements. 0 0.00000 1 0.500000 2 0.250000 3 0.750000 4 0.125000 5 0.625000 HALTON_SEED_GET reports current seed is 6 We jump to element 100 and compute 5 elements. 100 0.148437 101 0.648437 102 0.398437 103 0.898437 104 0.859375E-01 HALTON_SEED_GET reports current seed is 105 TEST04 HALTON_NUMBER_BASE_GET gets the current Halton base. HALTON_NUMBER_BASE_SET sets the current Halton base. The Halton base should be a prime, but this is not checked. In this test, we compute Halton numbers with the default base, then change the base, reset the seed, and recompute the numbers. HALTON_NUMBER_BASE_GET: Current base is 2 Element Halton 1 0.500000 2 0.250000 3 0.750000 4 0.125000 5 0.625000 6 0.375000 7 0.875000 8 0.625000E-01 9 0.562500 10 0.312500 Reset base to 3 Reset seed to 1 Element Halton 1 0.333333 2 0.666667 3 0.111111 4 0.444444 5 0.777778 6 0.222222 7 0.555556 8 0.888889 9 0.370370E-01 10 0.370370 Reset base to 4 Reset seed to 1 Element Halton 1 0.250000 2 0.500000 3 0.750000 4 0.625000E-01 5 0.312500 6 0.562500 7 0.812500 8 0.125000 9 0.375000 10 0.625000 TEST05 HALTON_VECTOR computes the elements of a vector Halton sequence. Each call produces the next value. By default, the bases are the first NDIM primes, and the sequence starts at element 1. In this test, we call HALTON_VECTOR several times, with the default bases. Element Halton 1 0.500000 0.333333 0.200000 0.142857 2 0.250000 0.666667 0.400000 0.285714 3 0.750000 0.111111 0.600000 0.428571 4 0.125000 0.444444 0.800000 0.571429 5 0.625000 0.777778 0.400000E-01 0.714286 6 0.375000 0.222222 0.240000 0.857143 7 0.875000 0.555556 0.440000 0.204082E-01 8 0.625000E-01 0.888889 0.640000 0.163265 9 0.562500 0.370370E-01 0.840000 0.306122 10 0.312500 0.370370 0.800000E-01 0.448980 TEST06 HALTON_VECTOR_SEQUENCE computes the next N elements of a vector Halton sequence. Each call produces the next value. By default, the bases are the first NDIM primes, and the sequence starts at element 1. In this test, we demonstrate how one call can compute many successive vector elements of the sequence. Element Halton 1 0.500000 0.333333 0.200000 0.142857 2 0.250000 0.666667 0.400000 0.285714 3 0.750000 0.111111 0.600000 0.428571 4 0.125000 0.444444 0.800000 0.571429 5 0.625000 0.777778 0.400000E-01 0.714286 6 0.375000 0.222222 0.240000 0.857143 7 0.875000 0.555556 0.440000 0.204082E-01 8 0.625000E-01 0.888889 0.640000 0.163265 9 0.562500 0.370370E-01 0.840000 0.306122 10 0.312500 0.370370 0.800000E-01 0.448980 TEST07 HALTON_SEED_SET specifies the next element of the Halton sequence to compute. HALTON_SEED_GET reports the next element of the Halton sequence that will be computed. By default, the sequence starts at element 1. In this test, we show how the seed changes as we compute elements, and how changing the seed changes the next element computed. We start at element 1 and compute 10 elements. We use a vector Halton sequence, with NDIM = 4 1 0.500000 0.333333 0.200000 0.142857 2 0.250000 0.666667 0.400000 0.285714 3 0.750000 0.111111 0.600000 0.428571 4 0.125000 0.444444 0.800000 0.571429 5 0.625000 0.777778 0.400000E-01 0.714286 6 0.375000 0.222222 0.240000 0.857143 7 0.875000 0.555556 0.440000 0.204082E-01 8 0.625000E-01 0.888889 0.640000 0.163265 9 0.562500 0.370370E-01 0.840000 0.306122 10 0.312500 0.370370 0.800000E-01 0.448980 HALTON_SEED_GET reports current seed is 11 We jump back to element 6 and compute 10 elements. 6 0.375000 0.222222 0.240000 0.857143 7 0.875000 0.555556 0.440000 0.204082E-01 8 0.625000E-01 0.888889 0.640000 0.163265 9 0.562500 0.370370E-01 0.840000 0.306122 10 0.312500 0.370370 0.800000E-01 0.448980 11 0.812500 0.703704 0.280000 0.591837 12 0.187500 0.148148 0.480000 0.734694 13 0.687500 0.481481 0.680000 0.877551 14 0.437500 0.814815 0.880000 0.408163E-01 15 0.937500 0.259259 0.120000 0.183673 HALTON_SEED_GET reports current seed is 16 We restart at element 0 and compute 6 elements. 0 0.00000 0.00000 0.00000 0.00000 1 0.500000 0.333333 0.200000 0.142857 2 0.250000 0.666667 0.400000 0.285714 3 0.750000 0.111111 0.600000 0.428571 4 0.125000 0.444444 0.800000 0.571429 5 0.625000 0.777778 0.400000E-01 0.714286 HALTON_SEED_GET reports current seed is 6 We jump to element 100 and compute 5 elements. 100 0.148437 0.411523 0.320000E-01 0.291545 101 0.648437 0.744856 0.232000 0.434402 102 0.398437 0.189300 0.432000 0.577259 103 0.898437 0.522634 0.632000 0.720117 104 0.859375E-01 0.855967 0.832000 0.862974 HALTON_SEED_GET reports current seed is 105 TEST08 HALTON_VECTOR_BASE_GET gets the current bases. HALTON_VECTOR_BASE_SET sets the current bases. HALTON_VECTOR_SEQUENCE computes the next N elements of a vector Halton sequence. Each call produces the next value. By default, the bases are the first NDIM primes, and the sequence starts at element 1. In this test, we compute the first 10 elements of the default sequence, then change bases, reset the seed to 1, and recompute the first 10 elements. Element Halton 1 0.500000 0.333333 0.200000 0.142857 2 0.250000 0.666667 0.400000 0.285714 3 0.750000 0.111111 0.600000 0.428571 4 0.125000 0.444444 0.800000 0.571429 5 0.625000 0.777778 0.400000E-01 0.714286 6 0.375000 0.222222 0.240000 0.857143 7 0.875000 0.555556 0.440000 0.204082E-01 8 0.625000E-01 0.888889 0.640000 0.163265 9 0.562500 0.370370E-01 0.840000 0.306122 10 0.312500 0.370370 0.800000E-01 0.448980 Current Halton bases: 2 3 5 7 New Halton bases: 3 7 13 19 Element Halton 1 0.333333 0.142857 0.769231E-01 0.526316E-01 2 0.666667 0.285714 0.153846 0.105263 3 0.111111 0.428571 0.230769 0.157895 4 0.444444 0.571429 0.307692 0.210526 5 0.777778 0.714286 0.384615 0.263158 6 0.222222 0.857143 0.461538 0.315789 7 0.555556 0.204082E-01 0.538462 0.368421 8 0.888889 0.163265 0.615385 0.421053 9 0.370370E-01 0.306122 0.692308 0.473684 10 0.370370 0.448980 0.769231 0.526316 TEST09 For the unit sphere in 2 dimensions (the circle): SPHERE_UNIT_HALTON_2D samples; A few sample values: 1.0000 0.0000 -0.5000 0.8660 -0.5000 -0.8660 0.7660 0.6428 -0.9397 0.3420 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: 0.0010 0.0001 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. We expect a value near 2 / PI = 0.6366... HALTON_SEED_RANDOMIZE Random Halton seed is = 1606663391 V: 0.5086 -0.8610 Average |(XdotV)| 0.6364 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606663497 V: 0.3988 0.9171 Average |(XdotV)| 0.6365 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606663602 V: 0.9645 0.2640 Average |(XdotV)| 0.6370 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606663706 V: 0.3073 -0.9516 Average |(XdotV)| 0.6362 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606663813 V: -0.9844 0.1758 Average |(XdotV)| 0.6369 TEST10 For the unit ball in 2 dimensions (the disk): BALL_UNIT_HALTON_2D samples; A few sample values: 0.0000 0.0000 0.3600 0.4514 -0.1817 0.7960 -0.3003 0.1446 -0.6006 -0.2893 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: -0.0012 0.0005 Now average the distance of the points from the center, which should be 1/2**(1/n) = 0.7071 Average: 0.6648 Now average the angle THETA, which should be PI. Average: 3.1254 TEST11 For the unit sphere in 3 dimensions: SPHERE_UNIT_HALTON_3D samples; A few sample values: 0.8236 -0.4782 -0.3050 0.8182 0.4468 0.3617 0.1142 0.6522 -0.7494 -0.6603 0.7464 -0.0828 -0.8108 -0.0414 0.5839 Now average the points, which should get a value close to zero, and closer as N increases. Average: 0.0009 0.0000 -0.0004 Now choose a random direction, sample the same number of points, and compute the dot product with the direction. Take the absolute value of each dot product and sum and average. HALTON_SEED_RANDOMIZE Random Halton seed is = 1606664894 V: -0.4911 0.6521 0.5775 Average |(XdotV)| 0.4995 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606665143 V: 0.8390 -0.3399 0.4248 Average |(XdotV)| 0.4989 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606665408 V: 0.4985 -0.7005 -0.5107 Average |(XdotV)| 0.4995 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606665651 V: -0.8061 -0.3035 -0.5080 Average |(XdotV)| 0.5007 HALTON_SEED_RANDOMIZE Random Halton seed is = 1606665889 V: -0.9383 -0.1880 -0.2903 Average |(XdotV)| 0.5003 TEST12 For the unit ball in 3 dimensions: BALL_UNIT_HALTON_3D samples; A few sample values: 0.0000 0.0000 0.0000 0.2500 0.3135 -0.1418 -0.1124 0.4925 0.1786 -0.3474 0.1673 -0.4771 -0.6045 -0.2911 -0.0750 Number of sample points = 1000 Now average the points, which should get a value close to zero, and closer as N increases. Average: -0.0007 0.0004 -0.0027 Now average the distance of the points from the center, which should be the 1/2**(1/n) = 0.7937 Average: 0.7476 Now average the angle THETA, which should be PI. Average: 3.1254 Now average the angle PHI, which should be PI/2. Average: NaN HALTON_PRB Normal end of execution.