Skip to content

Commit

Permalink
Merge pull request #69 from zenna/zt-prerelease
Browse files Browse the repository at this point in the history
Zt prerelease
  • Loading branch information
zenna committed Oct 8, 2018
2 parents c92dba6 + 3fdbcb8 commit 22e962b
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 33 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -6,7 +6,6 @@ os:
- osx
julia:
- 1.0
- 0.7
- nightly
notifications:
email: false
Expand Down
14 changes: 6 additions & 8 deletions Manifest.toml
Expand Up @@ -206,10 +206,10 @@ deps = ["Printf"]
uuid = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"

[[ProgressMeter]]
deps = ["Printf", "Random", "Test"]
git-tree-sha1 = "09e653f4b0a3c44628f0bdd0a0e58bc92e0264ef"
deps = ["Distributed", "Printf", "Random", "Test"]
git-tree-sha1 = "5b55c2c974084eab2689ec0d1d5245561b22aeb0"
uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
version = "0.6.0"
version = "0.6.1"

[[QuadGK]]
deps = ["DataStructures", "LinearAlgebra", "Test"]
Expand Down Expand Up @@ -267,11 +267,9 @@ deps = ["LinearAlgebra", "Random"]
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[Spec]]
deps = ["Cassette"]
git-tree-sha1 = "275d533031b8c97b6ca38b83395a435524a3dc46"
repo-rev = "master"
repo-url = "https://github.com/zenna/Spec.jl"
uuid = "526a04b8-654b-11e8-1588-db2a414f95b5"
deps = ["Cassette", "Test"]
git-tree-sha1 = "f1839be7daf5bf850406255be00490273eb380ee"
uuid = "b8ccf107-3a88-5e0f-823b-b838c6a0f327"
version = "0.1.3"

[[SpecialFunctions]]
Expand Down
3 changes: 1 addition & 2 deletions Project.toml
Expand Up @@ -7,10 +7,9 @@ version = "0.1.0"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
PDMats = "90014a1f-27ba-587c-ab20-58faa44d9150"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Spec = "526a04b8-654b-11e8-1588-db2a414f95b5"
Spec = "b8ccf107-3a88-5e0f-823b-b838c6a0f327"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"

Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
@@ -1,4 +1,4 @@
julia 0.7
julia 1.0
Flux
Distributions
PDMats
Expand Down
12 changes: 7 additions & 5 deletions src/Omega.jl
Expand Up @@ -32,15 +32,15 @@ export RandVar, MaybeRV, ciid, isconstant, elemtype, params
include("cond.jl") # Conditioning
export cond

# Lifted random variable operatiosn
include("lift/containers.jl") # Array/Tuple primitives
export randarray, randtuple

# Higher-Order Inference
include("higher/Higher.jl")
using .Higher
export rcd, rid,

# Lifted random variable operatiosn
include("lift/containers.jl") # Array/Tuple primitives
export randarray, randtuple

# Lifting functions to RandVar domain
include("lift/lift.jl")
export @lift, lift
Expand Down Expand Up @@ -157,7 +157,9 @@ export succprob,

isleptokurtic,
entropy,
mean
mean,
prob,
lprob

# Lifted distributional functions
export lsuccprob,
Expand Down
2 changes: 1 addition & 1 deletion src/higher/Higher.jl
@@ -1,6 +1,6 @@
module Higher

using ..Omega: RandVar, ciid
using ..Omega: RandVar, ciid, randtuple, cond

include("rcd.jl") # Random Conditional Distribution
include("rid.jl") # Random Interventional Distribution
Expand Down
3 changes: 2 additions & 1 deletion src/higher/rcd.jl
@@ -1,5 +1,6 @@
"Random Conditional Distribution"
rcd(x::RandVar, θ::RandVar, eq = ==ₛ) = ciid-> cond(x, eq(θ, θ(ω))))
rcd(x::RandVar, θ::RandVar, eq = ==) = ciid-> cond(x, eq(θ, θ(ω))))
rcd(x::RandVar, θs::Tuple, eq = ==) = rcd(x, randtuple(θs), eq)

"`rcd`, x ∥ y"
x y = rcd(x, y)
4 changes: 2 additions & 2 deletions src/lift/lift.jl
Expand Up @@ -54,8 +54,8 @@ fnms = [:(Base.:-),
:(Base.:<),
]

Base.:^(x1::RandVar, x2::MaybeRV) = ciid(^, x1, x2) # FIXME: Only for 0.7 deprecations
Base.:^(x1::RandVar, x2::Integer) = ciid(^, x1, x2) # FIXME: Only for 0.7 deprecations
# Base.:^(x1::RandVar, x2::MaybeRV) = ciid(^, x1, x2) # FIXME: Only for 0.7 deprecations
# Base.:^(x1::RandVar, x2::Integer) = ciid(^, x1, x2) # FIXME: Only for 0.7 deprecations
macro lift(fnm::Union{Symbol, Expr}, n::Integer)
combinations = Iterators.product(((true,false) for i = 1:n)...)
combinations = Iterators.filter(any, combinations)
Expand Down
6 changes: 4 additions & 2 deletions src/primitive/Prim.jl
Expand Up @@ -9,7 +9,7 @@ using ..Util
using Spec
import Distributions
const Djl = Distributions
import Base: minimum
import Base: minimum, maximum

export bernoulli,
betarv,
Expand Down Expand Up @@ -79,7 +79,9 @@ export succprob,

isleptokurtic,
entropy,
mean
mean,
prob,
lprob

# Lifted distributional functions
export lsuccprob,
Expand Down
18 changes: 8 additions & 10 deletions src/primitive/statistics.jl
Expand Up @@ -16,17 +16,16 @@
# end

# mean(xs::RandVar{<:Array}) = RandVar{Float64, false}(mean, (xs,))
"Sample Mean"
mean(x::RandVar, n) = sum((rand(x, alg = RejectionSample) for i = 1:n)) / n

# "Probability that `x` is `true`"
# prob(x::RandVar{T}, n) where {T <: Bool} = mean(x, n)
# prob(x::RandVar{T}, n = 10000) where { T<: RandVar{Bool}} = RandVar{Float64}(prob, (x, n))
# lift(:prob, 1)
"Probability x is true"
prob(x::RandVar, n, israndvar::Type{Val{false}}) =
sum((rand(x, alg = RejectionSample) for i = 1:n)) / n
lprob(x::RandVar, n = 1000) = ciid(prob, x, n, Val{false})
prob(x::RandVar, n) = prob(x, n, Val{elemtype(x) <: RandVar})


# Issues.
# Must expect that type inference may fail, and allow providing of type
# Also allow separate functions
#
# const lmean = lprob

# Specializations
const unidistattrs = [:succprob, :failprob, :maximum, :minimum, :islowerbounded,
Expand All @@ -42,7 +41,6 @@ for func in unidistattrs
$(:l *ₛ func)(x::RandVar) = ciid($func, x, Val{false})
$func(x::RandVar) = $func(x, Val{elemtype(x) <: RandVar})
end
@show expr
eval(expr)
end

Expand Down
1 change: 1 addition & 0 deletions src/soft/soft.jl
Expand Up @@ -26,6 +26,7 @@ function d end
@inline d(x::Real, y::Real) = (xy = (x - y); xy * xy)
# @inline d(x::Vector{<:Real}, y::Vector{<:Real}) = norm(x - y)
@inline d(x::Vector{<:Real}, y::Vector{<:Real}) = sum(d.(x,y))
@inline d(x::NTuple{N, <: Real}, y::NTuple{N, <:Real}) where N = sum(d.(x,y))
@inline d(x::Array{<:Real}, y::Array{<:Real}) = norm(x[:] - y[:])

"Soft Equality"
Expand Down

0 comments on commit 22e962b

Please sign in to comment.