Omega.jl icon indicating copy to clipboard operation
Omega.jl copied to clipboard

`randarray` not defined in Basic Tutorial

Open h-spiess opened this issue 3 years ago • 3 comments

Hey,

I wanted to play around with Omega.jl a bit and started with the Basic Tutorial.

Unfortunately, randarray is not defined in

nflips = 4
coinflips_ = [Bernoulli.(weight, Bool) for i = 1:nflips] # this is an array of RVs
randarray(coinflips_)

I'm using

...
[1af16e33] Omega v0.2.0 `~/.julia/dev/Omega`
[31c24e10] Distributions v0.25.53
```.

Thanks :) i hope this gets sorted out because I think Omega.jl is a very interesting package :)

h-spiess avatar May 13 '22 17:05 h-spiess

I have found this version in https://github.com/zenna/Omega.jl/blob/ee7afa521566b5de94fde26e465b77e9f553d822/OmegaExamples/docs/basictutorial.jl

nflips = 4
coinflips = Mv(Bernoulli.(weight), 1:nflips) # this is an array of RVs
randsample(coinflips)

But this gives:

ERROR: MethodError: no method matching length(::OmegaCore.Var.Pw{Tuple{Member{Beta{Float64}, Int64}}, Type{Bernoulli}})
Closest candidates are:
  length(!Matched::Union{Base.KeySet, Base.ValueIterator}) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/abstractdict.jl:58
  length(!Matched::Union{Tables.AbstractColumns, Tables.AbstractRow}) at ~/.julia/packages/Tables/PxO1m/src/Tables.jl:175
  length(!Matched::Union{ArrayInterface.BidiagonalIndex, ArrayInterface.TridiagonalIndex}) at ~/.julia/packages/ArrayInterface/ZsAcl/src/array_index.jl:33
  ...

h-spiess avatar May 13 '22 17:05 h-spiess

Ah, I think I have found the current version:

nflips = 4
coinflips = manynth(Bernoulli.(weight), 1:nflips) # this is an array of RVs
randsample(coinflips)

works :)

h-spiess avatar May 13 '22 18:05 h-spiess

But afterwards the conditioning on observations is not working

observations = [1, 1, 1, 0]

condition = coinflips == observations # false
condition = coinflips .== observations # ERROR: MethodError: no method matching size(::Mv{UnitRange{Int64}, OmegaCore.Var.Pw{Tuple{Member{Beta{Float64}, Int64}}, Type{Bernoulli}}})
condition = coinflips ==ᵣ observations # ERROR: UndefVarError: ==ᵣ not defined
condition = coinflips ==ₚ observations # ERROR: UndefVarError: ==ₚ not defined
condition = coinflips ==ₛ observations # ERROR: MethodError: no method matching dist(::Mv{UnitRange{Int64}, OmegaCore.Var.Pw{Tuple{Member{Beta{Float64}, Int64}}, Type{Bernoulli}}}, ::Vector{Int64})
condition = coinflips ==̃ₚ observations # works but fails afterwards

weight_samples = randsample(weight |ᶜ condition, 10; alg = RejectionSample) # ERROR: MethodError: no method matching &(::Bool, ::SoftPredicates.DualSoftBool{SoftBool{Float64}})

Do you think it would be wise to wait until the API stabilizes?

h-spiess avatar May 13 '22 18:05 h-spiess