# Sampler for Categorical Rational Distributions

**URL:** https://discourse.julialang.org/t/sampler-for-categorical-rational-distributions/55077
**Category:** General Usage
**Tags:** question, package, distributions
**Created:** [February 11, 2021, 6:23pm UTC](https://discourse.julialang.org/t/sampler-for-categorical-rational-distributions/55077 "2021-02-11T18:23:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ian\_Slagle](https://avatars.discourse-cdn.com/v4/letter/i/b5a626/32.png) [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)
#### Post date: [February 11, 2021, 6:23pm UTC](https://discourse.julialang.org/t/sampler-for-categorical-rational-distributions/55077/1 "2021-02-11T18:23:56Z")

</div>

With the new Distributions update (this did not appear to happen several versions ago), this works

```julia
rand(Categorical([0.5, 0.5]))

```

and this works

```julia
Categorical([1//2, 1//2])

```

but this causes an error (“ArgumentError: Sampler for this object is not defined”)

```julia
rand(Categorical([1//2, 1//2]))

```

What am I doing wrong here?

---

<div class="post-metadata">

### Author: ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)
#### Post date: [February 11, 2021, 6:46pm UTC](https://discourse.julialang.org/t/sampler-for-categorical-rational-distributions/55077/2 "2021-02-11T18:46:34Z")

</div>

What versions are you using? These versions seem to work:

```julia
julia> rand(Categorical([1//2,1//2]))
2

(jl_waVJwl) pkg> st
      Status `/tmp/jl_waVJwl/Project.toml`
  [31c24e10] Distributions v0.24.12

julia> versioninfo()
Julia Version 1.6.0-rc1
Commit a58bdd9010 (2021-02-06 15:49 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_REVISE_INCLUDE = 1

```

---

<div class="post-metadata">

### Author: ![Ian\_Slagle](https://avatars.discourse-cdn.com/v4/letter/i/b5a626/32.png) [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)
#### Post date: [February 11, 2021, 6:57pm UTC](https://discourse.julialang.org/t/sampler-for-categorical-rational-distributions/55077/3 "2021-02-11T18:57:35Z")

</div>

I am on version 0.21.12 of Distributions, which is why it’s probably not working.  
However Pkg.update(“Distributions”) is leading to no changes. Is this due to me being on 1.6 beta?

---

<div class="post-metadata">

### Author: ![Ian\_Slagle](https://avatars.discourse-cdn.com/v4/letter/i/b5a626/32.png) [@Ian\_Slagle](https://discourse.julialang.org/u/Ian_Slagle)
#### Post date: [February 11, 2021, 7:46pm UTC](https://discourse.julialang.org/t/sampler-for-categorical-rational-distributions/55077/4 "2021-02-11T19:46:27Z")

</div>

It actually was due to a seperate package (ClassImbalance) that Distributions of higher versions required be uninstalled. It told me this when I tried to get the Github version. It is working as expected now
