CUQI-DTU / CUQIpy

https://cuqi-dtu.github.io/CUQIpy/
Apache License 2.0
48 stars 9 forks source link

Allow target=None (and init vars when target is set) #398

Closed nabriis closed 6 months ago

nabriis commented 8 months ago

Feature Allow samplers to be initialized without a target, i.e.,

sampler = NUTSNew()

then allow target to be set later via

sampler.target = target

Behavior should be the same as if setting target during init, i.e.,

sampler1 = NUTSNew(target)
sampler2 = NUTSNew()
sampler2.target = target

samples1 = sampler1.warmup(200).sample(200)
samples2 = sampler2.warmup(200).sample(200)

assert np.allclose(samples1, samples2)