@@ -807,12 +807,12 @@ samples from the prior.
807
807
"""
808
808
(model:: Model )() = model (Random. default_rng ())
809
809
function (model:: Model )(
810
- rng:: AbstractRNG ,
810
+ rng:: Random. AbstractRNG ,
811
811
varinfo:: AbstractVarInfo = VarInfo (),
812
812
sampler:: AbstractSampler = SampleFromPrior (),
813
813
)
814
814
spl_ctx = SamplingContext (rng, sampler, DefaultContext ())
815
- return evaluate!! (model, varinfo, spl_ctx)
815
+ return first ( evaluate!! (model, varinfo, spl_ctx) )
816
816
end
817
817
818
818
"""
@@ -833,12 +833,15 @@ evaluation by wrapping the model's context in a `SamplingContext`.
833
833
834
834
Returns a tuple of the model's return value, plus the updated `varinfo` object.
835
835
"""
836
- function sample!! (rng:: AbstractRNG , model:: Model , varinfo:: AbstractVarInfo )
836
+ function sample!! (rng:: Random. AbstractRNG , model:: Model , varinfo:: AbstractVarInfo )
837
837
sampling_model = contextualize (
838
838
model, SamplingContext (rng, SampleFromPrior (), model. context)
839
839
)
840
840
return evaluate!! (sampling_model, varinfo)
841
841
end
842
+ function sample!! (model:: Model , varinfo:: AbstractVarInfo )
843
+ return sample!! (Random. default_rng (), model, varinfo)
844
+ end
842
845
843
846
"""
844
847
evaluate!!(model::Model, varinfo)
@@ -978,7 +981,6 @@ Return the arguments and keyword arguments to be passed to the evaluator of the
978
981
# speeding up computation. See docs for `maybe_invlink_before_eval!!`
979
982
# for more information.
980
983
maybe_invlink_before_eval!! (varinfo, model),
981
- context_new,
982
984
$ (unwrap_args... ),
983
985
)
984
986
kwargs = model. defaults
@@ -1014,15 +1016,7 @@ Base.nameof(model::Model{<:Function}) = nameof(model.f)
1014
1016
Generate a sample of type `T` from the prior distribution of the `model`.
1015
1017
"""
1016
1018
function Base. rand (rng:: Random.AbstractRNG , :: Type{T} , model:: Model ) where {T}
1017
- x = last (
1018
- evaluate!! (
1019
- model,
1020
- SimpleVarInfo {Float64} (OrderedDict ()),
1021
- # NOTE: Use `leafcontext` here so we a) avoid overriding the leaf context of `model`,
1022
- # and b) avoid double-stacking the parent contexts.
1023
- SamplingContext (rng, SampleFromPrior (), leafcontext (model. context)),
1024
- ),
1025
- )
1019
+ x = last (sample!! (model, SimpleVarInfo {Float64} (OrderedDict ())))
1026
1020
return values_as (x, T)
1027
1021
end
1028
1022
@@ -1187,7 +1181,7 @@ function Distributions.loglikelihood(model::Model, chain::AbstractMCMC.AbstractC
1187
1181
end
1188
1182
1189
1183
"""
1190
- predict([rng::AbstractRNG,] model::Model, chain::AbstractVector{<:AbstractVarInfo})
1184
+ predict([rng::Random. AbstractRNG,] model::Model, chain::AbstractVector{<:AbstractVarInfo})
1191
1185
1192
1186
Generate samples from the posterior predictive distribution by evaluating `model` at each set
1193
1187
of parameter values provided in `chain`. The number of posterior predictive samples matches
0 commit comments