Skip to content

Commit

Permalink
Sampler code and example edits.
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-j-smith committed Feb 20, 2016
1 parent ada7cea commit 504c75a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions doc/examples/gk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ using Mamba

@everywhere extensions = quote
using Distributions
import Distributions: quantile
import Distributions: location, scale, skewness, kurtosis, minimum, maximum,
quantile

immutable GK <: ContinuousUnivariateDistribution
A::Float64
Expand All @@ -13,7 +14,7 @@ using Mamba

function GK(A::Real, B::Real, g::Real, k::Real, c::Real)
## check args
0.0 <= c < 1.0 || throw(Argumenterror("c must be 0 <= c < 1"))
0.0 <= c < 1.0 || throw(ArgumentError("c must be in [0, 1)"))

## create distribution
new(A, B, g, k, c)
Expand Down
4 changes: 2 additions & 2 deletions doc/mcmc/distributions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ New known, unknown, or unnormalized univariate distributions can be created and

#. Create a ``quote`` block for the new distribution. Assign the block a variable name, say ``extensions``, preceded by the ``@everywhere`` macro to ensure compatibility when **julia** is run in multi-processor mode.

#. The *Distributions* package contains types and method definitions for new distributions. Load the package and import the package's methods (indicated below) to be extended.
#. The *Distributions* package contains types and method definitions for new distributions. Load the package and import any of its methods (indicated below) that are extended.

#. Declare the new distribution subtype, say ``D``, within the block. Any constructors explicitly defined for the subtype should accept un-typed or abstract-type (``Real``, ``AbstractArray``, or ``DenseArray``) arguments. Implementing constructors in this way ensures that they will be callable with the *Mamba* ``Stochastic`` and ``Logical`` types.

Expand Down Expand Up @@ -147,7 +147,7 @@ New known, unknown, or unnormalized multivariate distributions can be created an

#. Create a ``quote`` block for the new distribution. Assign the block a variable name, say ``extensions``, preceded by the ``@everywhere`` macro to ensure compatibility when **julia** is run in multi-processor mode.

#. The *Distributions* package contains types and method definitions for new distributions. Load the package and import the package's methods (indicated below) to be extended.
#. The *Distributions* package contains types and method definitions for new distributions. Load the package and import any of its methods (indicated below) that are extended.

#. Declare the new distribution subtype, say ``D``, within the block. Any constructors explicitly defined for the subtype should accept un-typed or abstract-type (``Real``, ``AbstractArray``, or ``DenseArray``) arguments. Implementing constructors in this way ensures that they will be callable with the *Mamba* ``Stochastic`` and ``Logical`` types.

Expand Down
8 changes: 4 additions & 4 deletions doc/samplers/mala.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ end
n = 5000
sim1 = Chains(n, 3, names = ["b0", "b1", "s2"])
sim2 = Chains(n, 3, names = ["b0", "b1", "s2"])
scale = 0.1
Sigma = eye(3)
theta1 = MALAVariate([0.0, 0.0, 0.0], scale, logfgrad)
theta2 = MALAVariate([0.0, 0.0, 0.0], scale, Sigma, logfgrad)
sigma = 0.1
R = eye(3)
theta1 = MALAVariate([0.0, 0.0, 0.0], sigma, logfgrad)
theta2 = MALAVariate([0.0, 0.0, 0.0], sigma, R, logfgrad)
for i in 1:n
sample!(theta1)
sample!(theta2)
Expand Down
2 changes: 1 addition & 1 deletion src/samplers/amwg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sample!(v::AMWGVariate; args...) = sample!(v, v.tune.logf; args...)
function sample!(v::AMWGVariate, logf::Function; adapt::Bool=true)
tune = v.tune
setadapt!(v, adapt)
if adapt
if tune.adapt
tune.m += 1
amwg_sub!(v, logf)
if tune.m % tune.batchsize == 0
Expand Down

0 comments on commit 504c75a

Please sign in to comment.