Closed zsunberg closed 2 years ago
Hmm, does IntervalSets actually implement rand? I seem to get an error:
julia> using IntervalSets; rand(1..2)
ERROR: ArgumentError: Sampler for this object is not defined
Apart from that, did you have any issues implementing rand
? If so perhaps I can help.
Not sure that this package itself is the place though. There is a point_in_domain
function to generate exactly one point of a domain, which is mainly used for testing purposes (and is incredibly helpful for that).
First of all, thank you, @daanhb and everyone else for making this package - we have been needing something to represent these types of spaces for a while: JuliaPOMDP/POMDPs.jl#301, JuliaReinforcementLearning/CommonRLSpaces.jl#14 (also, it seems quite a challenge to deal with all of the conceptual issues and different use cases people have - I admire your valor in attempting that 😃 )
Thanks!
It works for me with IntervalSets 0.7.1
julia> using IntervalSets
julia> rand(1..2)
1.0824522848444758
Apart from that, did you have any issues implementing rand? If so perhaps I can help.
No, it should not be a terrible challenge to implement. It is just a communication/packaging/conceptual issue. If I implement rand(::DomainSets.Rectangle)
in package P, and someone else implements it in package Q, things could get confusing if you use both P and Q.
So, the question is where to implement it. Since rand
belongs to Base
and DomainSets
owns the types, it seems like here would be the only safe place. Maybe another package like DomainSetsRandom
?
(to be clear, I'm happy to make a PR for the low hanging fruit cases at least but just want to make sure package maintainers are on board before I jump in)
Well if IntervalSets has it, we are just extending. Why don't you aim for a file like src/applications/rand.jl to get started, thanks for offering.
First of all, thank you, @daanhb and everyone else for making this package - we have been needing something to represent these types of spaces for a while: https://github.com/JuliaPOMDP/POMDPs.jl/issues/301, https://github.com/JuliaReinforcementLearning/CommonRLSpaces.jl/issues/14 (also, it seems quite a challenge to deal with all of the conceptual issues and different use cases people have - I admire your valor in attempting that :smiley: )
One thing that we commonly need in our applications is to get a random element of a set, for example
rand(ProductDomain(1..2, 3..4))
.Do you think that this package should include
rand
?On one hand, this does not make a ton of sense because it is not clear what distribution this should be drawn from (uniform would be a natural choice, but may be hard to implement for some sets), but on the other hand, many other sets without distributions support
rand
, i.e. (rand(Set([1,2]))
,rand(1..2)
).If
rand
does not belong in this package, where should it go?