-
-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
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
First vectorized approach in intro is incorrect algorithm. #37
Comments
Thanks, I didn't noticed sample was doing sampling without replacement. I'll change in favor of your solution which is also more readable. But in this specific case, taking n samples among 2n samples (having only 2 different values), would that make a statistical difference ? I'll also correct the Functional approach since the term is ambiguous as you underlined. Thanks again. |
Cool. Glad to be able to help. |
So I started reading the book and have gotten to the introduction so far (section 2.1). I noted a couple of issues and thought "I can help!...kinda".
The first vectorized approach to the random walk, which used the code
steps = random.sample([1, -1]*n, n)
does not in fact produce a random walk.This is because the
random.sample()
function performs sampling without replacement. All other random walk definitions I have seen, including the rest of the ones in the introduction, perform their sampling with replacement.In order to bring this implementation into line with the others in the introduction I might suggest using the
random.choices()
function.steps = random.choices([1,-1], k=n)
I also noticed a minor notational issue that could use some clarification. I believe that many people would refer to the "Functional approach" as a "Procedural approach". The word "Functional" is sometimes reserved for the functional programming style which makes heavy use of higher order functions. I cannot say, however, how universal such terminology is.
Looking forward to reading onward.
The text was updated successfully, but these errors were encountered: