Skip to content
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

Box muller chapter #974

Merged
merged 19 commits into from
May 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updating box_muller code
leios committed Mar 15, 2022
commit ea94c2801ac56e6441879246c5f652bc36a5b7dd
6 changes: 3 additions & 3 deletions contents/box_muller/code/julia/box_muller.jl
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@ function create_grid(n, endpoints)
for i = 1:axis_num
for j = 1:axis_num
a[(i - 1) * axis_num + j, :] .=
[i * dx * grid_extents + endpoints[1],
j * dx * grid_extents + endpoints[1]]
[i * dx + endpoints[1],
j * dx + endpoints[1]]
end
end

@@ -60,7 +60,7 @@ function polar_box_muller(input_pts, sigma, mu)

# this method is only valid for points within the unit circle
if r_0 == 0 || r_0 > 1
return [0,0]
return [NaN, NaN]
end

return [sigma * input_pts[1] * sqrt(-2 * log(r_0) / r_0) + mu,