Is there a way to symbolically represent the random sum of a random variable?

Viewed 34

Say I have some random distret random variable N, and some other random variable X. I want to make a new compund random variable Y as follows.

Y = \sum_{i=1}^{N} X_{i}

where X_i are independent and identically distributed random variables from the same distribution as X. (Sorry for the code block, I have too low rep to post pictures.)

So codewise I'd begin with somethine like

from sympy import abc, stats, S
N = stats.Geometric(name='N', p=S.One/2)
X = stats.Normal(name='X')

or whatever distributions I was interested in for the discrete and summand random variable. I've been looking at the docs and examples, but can't find a way to represent the compund variable I'm interested in. Then be able to invoke stats.E(Y) or stats.variance(Y).

I know I can calculate conditional expected values and variances along with other computations to calculate the "total" expected value and "total" variance. I can do that on my own, but I'd like to verify that work with a direct symbolic construction then invoke.

1 Answers

Until you stick to the normal distribution, like in your example, the sum is the same normal random variable, which E and var you may need to sweat to get to, given the discrete random variable is exotic. But if you deviate from normal, ooh-la-la, the things will become very nasty real quick. Monte Carlo is often the only solution. In the place of sympy developers, I would stay away from this mess.

Related