Forecaster Sampling Issue

Hi,

I am using forecasting framework. Basically, my model looks like this

	data_dim = zero_data.size(-1)
	feature_dim = covariates.size(-1)
	bias = pyro.sample('bias', dist.Normal(0, 5.0).expand([data_dim]).to_event(1)) 
	weight = pyro.sample('weight', dist.Normal(0, 1.0).expand([feature_dim]).to_event(1)) #0.1

	duration = zero_data.size(-2)
	prediction = (bias + (weight * covariates).sum(-1, keepdim=True))
	assert prediction.shape[-2:] == zero_data.shape
	init_dist = dist.Normal(0, 10.0).expand([1]).to_event(1)
	timescale = pyro.sample("timescale", dist.LogNormal(math.log(24), 1))
	trans_matrix = torch.exp(-1 / timescale)[..., None, None]
	trans_scale = pyro.sample("trans_scale", dist.LogNormal(-0.5 * math.log(24), 1))
	trans_dist = dist.Normal(0, trans_scale.unsqueeze(-1)).to_event(1)
	obs_matrix = torch.tensor([[1.]])
	
	with pyro.plate("a", covariates.size(-2), dim=-1):
		obs_scale = pyro.sample("obs_scale", dist.LogNormal(-2, 1))
	obs_scale = periodic_repeat(obs_scale, duration, dim=-1)
	obs_dist = dist.Normal(0, obs_scale.unsqueeze(-1)).to_event(1)
	noise_dist = dist.GaussianHMM(init_dist, trans_matrix, trans_dist, obs_matrix, obs_dist, duration=duration)
	self.predict(noise_dist, prediction)

pretty much the same as the one in state space model. After training the model, I was able to get quantiles for the samples in the model using

forecaster.guide.quantiles(quantiles=[0.01, 0.5, 0.99])

here’s how the samples look like:

'bias': tensor([[0.2104],
        [0.3108],
        [0.4113]])
'weight': tensor([[0.8498],
        [0.8671],
        [0.8844]])
'obs_scale': tensor([[0.0361, 0.0352, 0.0342,  ..., 0.0340, 0.0352, 0.0654],
        [0.1182, 0.1122, 0.1101,  ..., 0.1092, 0.1143, 0.2415],
        [0.3869, 0.3573, 0.3547,  ..., 0.3506, 0.3708, 0.8916]])}

which looks good to me, and now I want to test it out on how well it behaves on test set by using

num_samples = 20
samples = forecaster(data[T0:T1], covariates, num_samples=num_samples)
results_for_first_index = [:,0,0,0]
print(covariates[T1]
print(results_for_first_index)

and it gives me

tensor([3.9338])
tensor([-1.1955,  0.2780, -0.0045,  0.6129, -0.3032,  0.1798, -0.4130, -0.3543,
        -1.6007, -1.3558, -0.8315, -0.9361,  0.3496,  0.9461, -1.3984,  0.1729,
        -0.8567,  0.2006, -0.9516,  0.0439])

This is unexpected as I do expect something more or less around 0.87*3.94 + 0.31 +0 = 3.73, but no sample is anywhere near. Please let me know if I am doing anything wrong here. In addition, what’s the best way, under forecasting framework, to check the “trajectories” of each samples, or more ideally posterior distribution in general? Thanks in advance.