AllenDowney / ThinkStats2

Text and supporting code for Think Stats, 2nd Edition
http://allendowney.github.io/ThinkStats2/
GNU General Public License v3.0
4.01k stars 11.23k forks source link

mismatch between documentation and code in thinkstats2.Jitter #207

Closed rjoberon closed 11 months ago

rjoberon commented 1 year ago

The documentation for Jitter states Jitters the values by adding a uniform variate in (-jitter, jitter) but the code does

np.random.normal(0, jitter, n) + values

which is normal distributed data which is not necessarily (rather unlikely) in the range (-jitter, jitter).

Either the documentation should be changed or the code to

np.random.uniform(-jitter, jitter, n)

(which would also better fit the purpose in Ch. 5 to "undo" rounding)

AllenDowney commented 11 months ago

Fixed. Thank you!