A state space model (SSM) posits a set of latent (unobserved) variables that evolve over time with dynamics specified by a probabilistic transition model p(z[t+1] | z[t]). At each timestep, we observe a value sampled from an observation model conditioned on the current state, p(x[t] | z[t]). The special case where both the transition and observation models are Gaussians with mean specified as a linear function of the inputs, is known as a linear Gaussian state space model and supports tractable exact probabilistic calculations; see tfd_linear_gaussian_state_space_model for details. The local level model is a special case of a linear Gaussian SSM, in which the latent state posits a level evolving via a Gaussian random walk:

level[t] = level[t-1] + Normal(0., level_scale)
  observation_noise_scale = 0,
  initial_step = 0,
  validate_args = FALSE,
  allow_nan_stats = TRUE,
  name = NULL



Scalar integer tensor number of timesteps to model with this distribution.


Scalar (any additional dimensions are treated as batch dimensions) float tensor indicating the standard deviation of the level transitions.


instance of tfd_multivariate_normal representing the prior distribution on latent states. Must have event shape [1] (as tfd_linear_gaussian_state_space_model requires a rank-1 event shape).


Scalar (any additional dimensions are treated as batch dimensions) float tensor indicating the standard deviation of the observation noise.


Optional scalar integer tensor specifying the starting timestep. Default value: 0.


logical. Whether to validate input with asserts. If validate_args is FALSE, and the inputs are invalid, correct behavior is not guaranteed. Default value: FALSE.


logical. If FALSE, raise an exception if a statistic (e.g. mean/mode/etc...) is undefined for any batch member. If TRUE, batch members with valid parameters leading to undefined statistics will return NaN for this statistic. Default value: TRUE.


string name prefixed to ops created by this class. Default value: "LocalLevelStateSpaceModel".


an instance of LinearGaussianStateSpaceModel.


The latent state is [level] and [level] is observed (with noise) at each timestep.

The parameters level_scale and observation_noise_scale are each (a batch of) scalars. The batch shape of this Distribution is the broadcast batch shape of these parameters and of the initial_state_prior.

Mathematical Details

The local level model implements a tfp$distributions$LinearGaussianStateSpaceModel with latent_size = 1 and observation_size = 1, following the transition model:

transition_matrix = [[1]]
transition_noise ~ N(loc = 0, scale = diag([level_scale]))

which implements the evolution of level described above, and the observation model:

observation_matrix = [[1]]
observation_noise ~ N(loc = 0, scale = observation_noise_scale)

See also