evaluate
sampler¶
This is a dummy sampler that just evaluates the likelihood at a reference point. You can use it to test your likelihoods (take a look too at the model wrapper for a similar but more interactive tool).
To use it, simply make the sampler
block:
sampler:
evaluate:
# Optional: override parameter values
override:
# param: value
The posterior will be evaluated at a point sampled from the reference pdf (which may be a fixed value) or from the prior if there is no reference. Values passed through evaluate:override
will take precedence. For example:
params:
a:
prior:
min: 1
max: 1
ref: 0.5
b:
prior:
min: 1
max: 1
ref:
dist: norm
loc: 0
scale: 0.1
c:
prior:
min: 1
max: 1
d:
prior:
min: 1
max: 1
ref: 0.4
sampler:
evaluate:
override:
d: 0.2
In this case, the posterior will be evaluated for each parameter at:
a: Exactly at \(0.5\).
b: Sampled from the reference pdf: a Gaussian centred at \(0\) with standard deviation \(0.1\).
c: From the prior, since there is no reference pdf: sampled uniformly in the interval \([1, 1]\).
d: From the override
, which takes precedence above all else.
Note
If using this sampler cobaya appears to be stuck, this normally means that it cannot sample a point with finite posterior value. Check that your prior/likelihood definitions leave room for some finite posterior density, e.g. don’t define an external prior that imposes that \(x>2\) if the range allowed for \(x\) is just \([0,1]\).
Sampler class¶
Synopsis:  Dummy “sampler”: simply evaluates the likelihood. 

Author:  Jesus Torrado 

class
samplers.evaluate.
evaluate
(info_sampler, model, output, resume=False, modules=None)¶ 
initialize
()¶ Creates a 1point collection to store the point at which the posterior is evaluated.

run
()¶ First gets a reference point. If a single reference point is not given, the point is sampled from the reference pdf. If that one is not defined either, the point is sampled from the prior.
Then it evaluates the prior and likelihood(s) and stores them in the onemember sample collection.

close
(exception_type, exception_value, traceback)¶ Writes the output: the point and its prior, posterior and likelihood.

products
()¶ Auxiliary function to define what should be returned in a scripted call.
Returns: The sample Collection
containing the sequentially discarded live points.
