03-Jul-2023 10:42:21 walker_sample_test(): MATLAB/Octave version 5.2.0. Test walker_sample() normalize_test(): normalize() normalizes entries 1 through N of a vector of length N+2. Initial X: 1: 0.769853 2: 0.701797 3: 0.247491 4: 0.263604 5: 0.519571 6: 0.201338 7: 0.91287 Initial L1 norm of X(1:N) = 1.9338 Normalized X: 1: 0.769853 2: 0.36291 3: 0.127982 4: 0.136314 5: 0.268679 6: 0.104115 7: 0.91287 Final L1 norm of X(1:N) = 1 NORMALIZE_TEST Normal end of execution. r8vec_print_test(): r8vec_print() prints an R8VEC. The R8VEC: 1: 123.456 2: 5e-06 3: -1e+06 4: 3.14159 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): 1: 0 2: 0.0625 3: 0.25 4: 0.375 5: 0.25 6: 0.0625 7: 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_BUILD_TEST Normal end of execution. walker_sampler_test(): walker_sampler() creates Walker sample vectors Y and A for efficiently sampling 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.0179238 2 0.161314 3 0.0716953 4 0.0100822 5 0.0258103 6 0.0403286 7 0.00796615 8 0.645258 9 0.0131685 10 0.00645258 Built the sampler i Y(i) A(i): 1 0.179238 8 2 1 2 3 0.716953 8 4 0.100822 8 5 0.258103 8 6 0.403286 8 7 0.0796615 8 8 0.386855 2 9 0.131685 8 10 0.0645258 8 100000 samples: prob #samples: 0.0179238 1751 0.161314 16184 0.0716953 7367 0.0100822 1003 0.0258103 2546 0.0403286 4076 0.00796615 794 0.645258 64263 0.0131685 1377 0.00645258 639 sumvar = 1.14161 (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): 1: 0 2: 0.30103 3: 0.176091 4: 0.124939 5: 0.09691 6: 0.0791812 7: 0.0669468 8: 0.0579919 9: 0.0511525 10: 0.0457575 11: 0 I A(I) Y(i) (ignore first and last entries) 0 0 0 1 1 1 2 1 0.896612 3 2 0.72697 4 2 0.87219 5 2 0.712631 6 3 0.602521 7 1 0.521928 8 1 0.460373 9 1 0.411817 10 10 2 The verification sum = 1.38778e-16 It should be very close to zero. walker_verify_test(): Normal end of execution. 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 Nin a Zipf distribution with parameter P. X for N = 5, P = 1.0 1: 0 2: 0.437956 3: 0.218978 4: 0.145985 5: 0.109489 6: 0.0875912 7: 0 X for N = 5, P = 2.0 1: 0 2: 0.683242 3: 0.17081 4: 0.0759157 5: 0.0427026 6: 0.0273297 7: 0 X for N = 10, P = 2.0 1: 0 2: 0.645258 3: 0.161314 4: 0.0716953 5: 0.0403286 6: 0.0258103 7: 0.0179238 8: 0.0131685 9: 0.0100822 10: 0.00796615 11: 0.00645258 12: 0 ZIPF_PROBABILITY_TEST Normal end of execution. walker_sample_test(): Normal end of execution. 03-Jul-2023 10:42:42