Search code examples
tensorflow-probability

How to add random variables in Tensorflow Probability


Given N independent binomial variables (not identically distributed), how does one compute the probability distribution of the sum of those random variables, in the form of a TensorFlow Probability Distribution object?


Solution

  • Convolution is not analytic in-general. For binomial, if the p parameter is the same and only the counts differ, you can sum the counts.

    If all you want to do is sample, you can write tf.reduce_sum(tfd.Binomial(total_count=[1, 2, 3], probs=[.2, .3, .4]).sample()).

    Computing log_prob(x) would require evaluating all legal allocations of x across all the underlying distributions, or using MCMC, ABC, or other schemes.