def sample_posterior(self, session=None, return_stats=False, **kwargs):
"""
Returns a new sample from the posterior distribution of the parameters.
:param return_stats: Whether to return sampling process statistics
:return: the generated sample
"""
# make a number of tries to draw a sample
for i in range(self.draw_retries_num):
sample, stats = self._sample_posterior(session=session, return_stats=return_stats, **kwargs)
if sample is not None:
break
if sample is not None:
self.sample_number += 1
else:
logging.warning('Impossible to draw a sample with the specified parameters.')
if return_stats:
return sample, stats
return sample
评论列表
文章目录