Tue May 20 22:50:30 2025 walker_sample_test(): python version: 3.10.12 numpy version: 1.26.4 Test walker_sample() normalize_test(): normalize() normalizes entries 1 through N of a vector of length N+2. Initial X: 0: 0.334565 1: 0.810064 2: 0.400484 3: 0.959629 4: 0.527773 5: 0.0767511 6: 0.372681 Initial L1 norm of X(1:5) = 2.7747 Normalized X: 0: 0.334565 1: 0.291946 2: 0.144334 3: 0.34585 4: 0.190209 5: 0.027661 6: 0.372681 Final L1 norm of X(1:5) = 1 r8vec_indicator0_test(): r8vec_indicator0() returns an indicator matrix. The indicator0 vector: [0. 1. 2. 3. 4. 5. 6. 7. 8. 9.] random_permutation_test(): random_permutation() randomly permutes entries 1 through N of a vector X[0:N+1]. Initial X: 0: 0 1: 1 2: 2 3: 3 4: 4 5: 5 6: 6 Permuted X: 0: 0 1: 2 2: 1 3: 4 4: 3 5: 5 6: 6 walker_build_test(): walker_build() builds the Walker sampler data vectors Y and A, given a probability vector X. Binomial PDF (ignore first and last entries): 0: 0 1: 0.0625 2: 0.25 3: 0.375 4: 0.25 5: 0.0625 6: 0 I A[I] Y[i] (ignore first and last entries) 0 0 0 1 3 0.3125 2 2 1 3 4 0.5 4 2 0.75 5 3 0.3125 6 6 2 walker_sampler_test(): walker_sampler() creates Walker sample vectors Y and A for efficient sampling of a discrete probability vector. Test the Walker sampler with a Zipf-type probability. Zipf probabilities for N = 10 and parameter P = 2 I X[I] 1 0.645258 2 0.161314 3 0.0716953 4 0.0403286 5 0.0258103 6 0.0179238 7 0.0131685 8 0.0100822 9 0.00796615 10 0.00645258 Randomly permuted X: I X[I] 1 0.0131685 2 0.0403286 3 0.00645258 4 0.645258 5 0.0179238 6 0.0100822 7 0.0258103 8 0.00796615 9 0.0716953 10 0.161314 Built the sampler i Y[i] A[i]: 0 0 0 1 0.131685 4 2 0.403286 4 3 0.0645258 4 4 0.386855 10 5 0.179238 4 6 0.100822 4 7 0.258103 4 8 0.0796615 4 9 0.716953 4 10 1 10 11 2 11 100000 samples: prob #samples: 0.0131685 1282 0.0403286 4112 0.00645258 687 0.645258 64589 0.0179238 1847 0.0100822 997 0.0258103 2655 0.00796615 809 0.0716953 7006 0.161314 16016 sumvar = 1.38953, (should be about 1) walker_verify_test(): walker_verify() verifies the Walker sampler data vectors Y and A, for a given probability vector X. Benford PDF (ignore first and last entries): 0: 0 1: 0.30103 2: 0.176091 3: 0.124939 4: 0.09691 5: 0.0791812 6: 0.0669468 7: 0.0579919 8: 0.0511525 9: 0.0457575 10: 0 I A[I] Y[i] (ignore first and last entries) 0 0 0 1 1 1 2 1 0.8966 3 2 0.727 4 2 0.8722 5 2 0.7126 6 3 0.6025 7 1 0.5219 8 1 0.4604 9 1 0.4118 10 10 2 The verification sum = 1.38778e-16 It should be very close to zero. zipf_probability_test(): zipf_probability() sets up a probablity vector X of N+2 elements containing in X[1:N] the probabilities of outcomes 1 through N in a Zipf distribution with parameter P. X for N = 5, P = 1.0 0: 0 1: 0.437956 2: 0.218978 3: 0.145985 4: 0.109489 5: 0.0875912 6: 0 X for N = 5, P = 2.0 0: 0 1: 0.683242 2: 0.17081 3: 0.0759157 4: 0.0427026 5: 0.0273297 6: 0 X for N = 10, P = 2.0 0: 0 1: 0.645258 2: 0.161314 3: 0.0716953 4: 0.0403286 5: 0.0258103 6: 0.0179238 7: 0.0131685 8: 0.0100822 9: 0.00796615 10: 0.00645258 11: 0 walker_sample_test(): Normal end of execution. Tue May 20 22:50:31 2025