# Observable for holding any Univariate Distribution

**URL:** https://discourse.julialang.org/t/observable-for-holding-any-univariate-distribution/125876
**Category:** General Usage
**Created:** [February 13, 2025, 7:11pm UTC](https://discourse.julialang.org/t/observable-for-holding-any-univariate-distribution/125876 "2025-02-13T19:11:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rand5](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rand5/32/867_2.png) [@rand5](https://discourse.julialang.org/u/rand5)
#### Post date: [February 13, 2025, 7:11pm UTC](https://discourse.julialang.org/t/observable-for-holding-any-univariate-distribution/125876/1 "2025-02-13T19:11:48Z")

</div>

How would one create an Observable to hold any univariate distribution?

If I do,

```julia
using Interact, Distributions
h = Observable(Normal())

```

The observable only accepts Normals, so the following fails:

```julia
h[] = Gamma()

```

---

<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 13, 2025, 7:19pm UTC](https://discourse.julialang.org/t/observable-for-holding-any-univariate-distribution/125876/2 "2025-02-13T19:19:48Z")

</div>

You can create an `Observable` with type `Distribution`, but beware of performance problems since this is not a concrete type.

```julia
julia> typeof(Normal())
Normal{Float64}

julia> supertype(ans)
Distribution{Univariate, Continuous}

julia> h = Observable{Distribution}()
Observable{Distribution}(#undef)

julia> h[] = Normal()
Normal{Float64}(μ=0.0, σ=1.0)

julia> h[] = Gamma()
Gamma{Float64}(α=1.0, θ=1.0)

```
