I googled empirical distribution examples however found no code examples
my code is :
def bayesian_volume_model(tick_data_series):
p_sell_lambda=sample("lambda", Empirical())
for each in range(tick_data_series.__len__()):
sample("obs_s_{}".format(each),Poisson(p_sell_lambda),obs=tick_data_series[each])
pass
def bayesian_volume_guide(tick_data_series):
sample("lambda",Empirical())
pass
it raises exception as:
File "D:\bin\miniconda3_x64\lib\site-packages\pyro\distributions\empirical.py", line 109, in sample
idxs = self._categorical.sample(sample_shape=sample_shape)
AttributeError: 'NoneType' object has no attribute 'sample'
EDIT added backtick formatting
The Empirical
distribution is mostly used internally to store weighted samples from the posterior distribution, e.g. from MCMC or importance sampling. I don’t think you would want to use this in your model directly. It will help if you explained what is it that you are looking to do - why does p_sell_lambda
have to be from an “empirical” distribution?
the data of stock sell/buy order follows poisson distribution, whose lambda is frequently changing. here I use empirical for the lambda parameter.
the continuous incoming data refreshes the posterior lambda parameter.
The Empirical
distribution shouldn’t be used here. You could place a gamma
prior on lambda
instead. If you meant that you are looking to model how lambda
changes over time, I suppose you will need to build that into your model.