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

Inconsistent sampling type for Uniform{BigFloat} #1252

Open
yurivish opened this issue Jan 7, 2021 · 0 comments · May be fixed by #1905
Open

Inconsistent sampling type for Uniform{BigFloat} #1252

yurivish opened this issue Jan 7, 2021 · 0 comments · May be fixed by #1905

Comments

@yurivish
Copy link
Contributor

yurivish commented Jan 7, 2021

While playing around with the Uniform distribution I noticed a seeming inconsistency between the results of generating a single sample from a high-precision uniform distribution using rand and generating multiple samples.

For a Uniform{BigFloat} distribution, a single sample using rand(dist) yields a BigFloat value while multiple samples using rand(dist, n) yield Float64 values.

julia> using Distributions

julia> dist = Uniform(BigFloat(0), BigFloat(1))
Uniform{BigFloat}(a=0.0, b=1.0)

julia> rand(dist)
0.518440823260704508612661811639554798603057861328125

julia> typeof(rand(dist))
BigFloat

julia> rand(dist, 2)
2-element Array{Float64,1}:
 0.8587350116719372
 0.6892639654172594

julia> typeof(rand(dist, 2))
Array{Float64,1}

julia> versioninfo()
Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.7.0)
  CPU: Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant