-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
rand(::Range) computes elements incorrectly for FloatRange #8257
Labels
randomness
Random number generation and the Random stdlib
Comments
Why do we even have a
|
ivarne
added a commit
to ivarne/julia
that referenced
this issue
Sep 8, 2014
This version of `rand(r::Range)` and `rand!(r::Range,a::AbstractArray)` uses getindex instead of trying to calculate the exact value of the range. This is good because we avoid duplicating the getindex logic in `FloatRange`
ivarne
added a commit
to ivarne/julia
that referenced
this issue
Sep 8, 2014
This version of `rand(r::Range)` and `rand!(r::Range,a::AbstractArray)` uses getindex instead of trying to calculate the exact value of the range. This is good because we avoid duplicating the getindex logic in `FloatRange` Also added tests, and fixed a small issue in `in(v, r::Range)` where two calls to step() is not needed
ivarne
added a commit
to ivarne/julia
that referenced
this issue
Sep 8, 2014
This version of `rand(r::Range)` and `rand!(r::Range,a::AbstractArray)` uses getindex instead of trying to calculate the exact value of the range. This is good because we avoid duplicating the getindex logic in `FloatRange` Also added tests, and fixed a small issue in `in(v, r::Range)` where two calls to step() is not needed
ivarne
added a commit
to ivarne/julia
that referenced
this issue
Sep 8, 2014
This version of `rand(r::Range)` and `rand!(r::Range,a::AbstractArray)` uses getindex instead of trying to calculate the exact value of the range. This is good because we avoid duplicating the getindex logic in `FloatRange` Also added tests, and fixed a small issue in `in(v, r::Range)` where two calls to step() is not needed
ivarne
added a commit
to ivarne/julia
that referenced
this issue
Sep 10, 2014
This version of `rand(r::Range)` and `rand!(r::Range,a::AbstractArray)` uses getindex instead of trying to calculate the exact value of the range. This is good because we avoid duplicating the getindex logic in `FloatRange` Also added tests, and fixed a small issue in `in(v, r::Range)` where two calls to step() is not needed
ivarne
added a commit
that referenced
this issue
Sep 10, 2014
rfourquet
added a commit
to rfourquet/julia
that referenced
this issue
Sep 11, 2014
This implements the generalization suggested by @ivarne (JuliaLang#8257 (comment)) or by @lindahua (JuliaLang#6003 (comment)). This change is very simple thanks to commit 48f27bc.
rfourquet
added a commit
to rfourquet/julia
that referenced
this issue
Sep 11, 2014
This implements the generalization suggested by @ivarne (JuliaLang#8257 (comment)) or by @lindahua (JuliaLang#6003 (comment)). This change is very simple thanks to commit 48f27bc.
ivarne
added a commit
that referenced
this issue
Sep 15, 2014
This version of `rand(r::Range)` and `rand!(r::Range,a::AbstractArray)` uses getindex instead of trying to calculate the exact value of the range. This is good because we avoid duplicating the getindex logic in `FloatRange` Also added tests, and fixed a small issue in `in(v, r::Range)` where two calls to step() is not needed Backport of 48f27bc PR: #8273
rfourquet
added a commit
to rfourquet/julia
that referenced
this issue
Sep 17, 2014
This implements the generalization suggested by @ivarne (JuliaLang#8257 (comment)) or by @lindahua (JuliaLang#6003 (comment)). This change is very simple thanks to commit 48f27bc.
rfourquet
added a commit
to rfourquet/julia
that referenced
this issue
Sep 30, 2014
This implements the generalization suggested by @ivarne (JuliaLang#8257 (comment)) or by @lindahua (JuliaLang#6003 (comment)). This change is very simple thanks to commit 48f27bc.
rfourquet
added a commit
to rfourquet/julia
that referenced
this issue
Sep 30, 2014
This implements the generalization suggested by @ivarne (JuliaLang#8257 (comment)) or by @lindahua (JuliaLang#6003 (comment)). This change is very simple thanks to commit 48f27bc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
rand(r::Range)
just multiplies bystep(r)
instead of multiplying byr.step
and dividing byr.divisor
as in FloatRange indexing. This leads to cases where the return value is not actually in the range, e.g.rand(1:1/3:2) in 1:1/3:2
is sometimes false becauserand
returns1.6666666666666665
.The text was updated successfully, but these errors were encountered: