Scruff.Utils
Scruff.Utils.Factor — Typestruct Factor{N}Representation of a factor over N instances.
arguments
dims a tuple of dimensions of the instances
keys ids of the instances
entries a vector of factor valuesScruff.Utils.Graph — Typestruct GraphA simple graph with nodes (Int), edges (outgoing), and a size property for each node
Base.show — Methodfunction show(f::Factor)Print the factor in an easy to read format.
Scruff.Utils.bounded_linear_value — Methodbounded_linear_value(weights, bias, interval_combo)Weight and sum the upper and lower bounds in interval_combo with the given bias
Scruff.Utils.cartesian_product — Methodcartesian_product(xs::Tuple)
cartesian_product(xs::Array)Given an array of arrays, returns the cartesian product of those arrays.
Examples
julia> cartesian_product([[1,2],[3,4]])
4-element Array{Array{Int64,1},1}:
[1, 3]
[1, 4]
[2, 3]
[2, 4]
julia> cartesian_product([[1,2],[3,4],[5,6]])
8-element Array{Array{Int64,1},1}:
[1, 3, 5]
[1, 3, 6]
[1, 4, 5]
[1, 4, 6]
[2, 3, 5]
[2, 3, 6]
[2, 4, 5]
[2, 4, 6]Scruff.Utils.linear_value — Methodlinear_value(weights, bias, continuous_combo)Weight and sum the continuous_combo with the given bias
Scruff.Utils.make_intervals — Methodmake_intervals(range)Given a range of values of a continuous variable, create interval bins surrounding the values
Scruff.Utils.memo — Methodmemo(f::Function)returns a memoized one argument function
Scruff.Utils.nextkey — Functionnextkey()::IntProduce a fresh instance id that does not conflict with an existing id.
Scruff.Utils.normal_density — Methodnormal_density(x, mean, variance)Get the normal density of x
Scruff.Utils.normalize — Methodnormalize(xs)Normalize an array of non-negative reals to sum to 1
Scruff.Utils.normalize — Methodfunction normalize(f::Factor)Return a new factor equal to the given factor except that entries sum to 1
Scruff.Utils.normalized_product — Methodnormalized_product(xss, n)Compute the product of the given arrays of length n and normalize the result. Uses log computations to avoid underflow.
Scruff.Utils.topsort — Methodtopsort(graph::Dict{T, Vector{T}}) :: Vector{T} where TPerforms a topological sort on the given graph. In a cyclic graph, the order of variables in the cycle is arbitrary, but they will be correctly sorted relative to other variables.