Generate Autoregressive Random Variables for given initial states

23 views
Skip to first unread message

Konstantin Vasilev

unread,
May 17, 2022, 6:32:22 PMMay 17
to TensorFlow Probability

I've been trying to generate a set of AR(1) processes for a given set of initial states and AR params using tfp.distributions.Autoregressive. What I'm currently getting are processes with random initial states and I don't see how to set them as fixed:

import tensorflow_probability as tfp
import tensorflow as tf

model = tfp.sts.Autoregressive(order=1).make_state_space_model(
    num_timesteps=25,
    param_vals={
        'coefficients': [tf.constant(0.2)],
        'level_scale': tf.constant(0.5),
})

pd.DataFrame(model.sample(2).numpy()[:,:,0].T).plot()

Brian Patton 🚀

unread,
May 18, 2022, 6:30:38 AMMay 18
to Konstantin Vasilev, TensorFlow Probability
Something along the lines of .build_state_space_model(..).copy(initial_state_prior=[tfd.Deterministic(..), ..])
might do it.

You can look at ssm.parameters to understand the right structure for that argument.

https://www.tensorflow.org/probability/api_docs/python/tfp/distributions/LinearGaussianStateSpaceModel#args says it needs to be an MVN, so there's some risk this won't work, but you could at least make it very tightly concentrated, and the API doc might be over restrictive for sampling (maybe that constraint only applies for log prob and marginal).

--
You received this message because you are subscribed to the Google Groups "TensorFlow Probability" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfprobabilit...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfprobability/5e98b5be-acfc-4504-bdfb-a6269ffd2304n%40tensorflow.org.
Reply all
Reply to author
Forward
0 new messages