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

randarray not defined in Basic Tutorial #209

Open
h-spiess opened this issue May 13, 2022 · 3 comments
Open

randarray not defined in Basic Tutorial #209

h-spiess opened this issue May 13, 2022 · 3 comments

Comments

@h-spiess
Copy link

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
Copy link
Author

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
Copy link
Author

h-spiess commented May 13, 2022

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
Copy link
Author

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?

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