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

sampling from BetaSampler slower than directly from Beta #1830

Closed
adienes opened this issue Jan 27, 2024 · 1 comment
Closed

sampling from BetaSampler slower than directly from Beta #1830

adienes opened this issue Jan 27, 2024 · 1 comment

Comments

@adienes
Copy link
Contributor

adienes commented Jan 27, 2024

julia> _b = Beta(1, 20)
Beta{Float64}(α=1.0, β=20.0)

julia> _b2 = sampler(_b)
Distributions.BetaSampler{Float64, Exponential{Float64}, Distributions.GammaMTSampler{Float64}}(true, 1.0, 0.05, Exponential{Float64}(θ=1.0), Distributions.GammaMTSampler{Float64}(19.666666666666668, 0.07516460280028289, 19.666666666666668, 0.0331))

julia> @benchmark rand($rng, $_b)
BenchmarkTools.Trial: 10000 samples with 998 evaluations.
 Range (min … max):  18.119 ns … 53.231 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     19.747 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   19.862 ns ±  1.154 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

          ▁ ▄▆█▄█▆▅▃                                           
  ▂▂▂▂▃▄▅▆██████████▇▇▅▄▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂ ▃
  18.1 ns         Histogram: frequency by time          25 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> @benchmark rand($rng, $_b2)
BenchmarkTools.Trial: 10000 samples with 996 evaluations.
 Range (min … max):  21.754 ns … 79.401 ns  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     28.448 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   28.698 ns ±  1.924 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

                          ▁▃▆███▆▄▃▂▂                         ▂
  ▃▁▃▄▃▄▄▃▅▅▄▄▃▃▃▄▄▄▄▄▁▃▃▄████████████▇▇▇██▇▇▆▆▅▅▆▅▅▆▄▅▄▄▅▅▆▅ █
  21.8 ns      Histogram: log(frequency) by time      35.6 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.```



julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 8 virtual cores


Distributions v0.25.107
@adienes
Copy link
Contributor Author

adienes commented Jan 27, 2024

not sure how I got this but I think I was reading the wrong thing

@adienes adienes closed this as completed Jan 27, 2024
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

No branches or pull requests

1 participant