We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In Chapter 5, problem 10, reader is asked to generate a uniformly random number within a range [a,b].
The solution provided is not uniformly random. My method to test is given here:
https://gist.github.com/umbs/5b1557b585d2ed068d7169554db1e62d
Results after multiple runs within various ranges are:
[1] $ ./a.exe 1 10 1 = 0.000700 2 = 0.008300 3 = 0.046000 4 = 0.114200 5 = 0.206200 6 = 0.252600 7 = 0.199500 8 = 0.115600 9 = 0.045000 10 = 0.011400
==========
$ ./a.exe 10 15 10 = 0.015200 11 = 0.098200 12 = 0.235200 13 = 0.306700 14 = 0.238000 15 = 0.090900
===========
$ ./a.exe 101 120 101 = 0.000000 102 = 0.000000 103 = 0.000400 104 = 0.001300 105 = 0.005100 106 = 0.014100 107 = 0.038200 108 = 0.076600 109 = 0.115500 110 = 0.159100 111 = 0.173200 112 = 0.163000 113 = 0.119800 114 = 0.074000 115 = 0.037500 116 = 0.015400 117 = 0.005200 118 = 0.001400 119 = 0.000100 120 = 0.000100
The text was updated successfully, but these errors were encountered:
No branches or pull requests
In Chapter 5, problem 10, reader is asked to generate a uniformly random number within a range [a,b].
The solution provided is not uniformly random. My method to test is given here:
https://gist.github.com/umbs/5b1557b585d2ed068d7169554db1e62d
Results after multiple runs within various ranges are:
[1]
$ ./a.exe 1 10
1 = 0.000700
2 = 0.008300
3 = 0.046000
4 = 0.114200
5 = 0.206200
6 = 0.252600
7 = 0.199500
8 = 0.115600
9 = 0.045000
10 = 0.011400
==========
$ ./a.exe 10 15
10 = 0.015200
11 = 0.098200
12 = 0.235200
13 = 0.306700
14 = 0.238000
15 = 0.090900
===========
$ ./a.exe 101 120
101 = 0.000000
102 = 0.000000
103 = 0.000400
104 = 0.001300
105 = 0.005100
106 = 0.014100
107 = 0.038200
108 = 0.076600
109 = 0.115500
110 = 0.159100
111 = 0.173200
112 = 0.163000
113 = 0.119800
114 = 0.074000
115 = 0.037500
116 = 0.015400
117 = 0.005200
118 = 0.001400
119 = 0.000100
120 = 0.000100
The text was updated successfully, but these errors were encountered: