# Vector of binary variables with time dependency and a sum constraint

Imagine you have k binary variables that you observe over time. There is some (Markov like) persistence in each variable. But they also have a sum constraint s.

Each x can be modelled as a Bernoulli and the sum of x at each time step is Binomial() or Poisson-Binomial().

So first we determine the sum of x for time t and then we sample each x according to its previous value.

How would you model this?

x \in \{0, 1\}

\sum_i x_{it} = s_t

s_t \sim s_{t-1}

x_{it} | s_t \sim x_{it-1}

It’s a bit like a multivariate HMM.

I might think to model the probabilities using independent auto-logistic regressions. The question then is how to enforce an exact sum constraint. Brute force would require normalizing over all k choose s possible combinations, which I guess might be prohibitive for you (but maybe not if k is sufficiently small?). Maybe @spinkney has a clever trick for how to avoid brute force normalization here.