# How to denote a sum of $n$ samples from a distribution?

Just a simple notational question: I want to concisely denote sampling $$n$$ times from a distribution and summing over a function applied to the samples. I am not sure how to do this however. I cannot define a set of $$X_i$$ as global variables ahead, because the summation occurs in the scope of an outer summation. And each ieration the inner sum samples anew. Currently, I have

$$\sum_k^N\sum_{x \sim X}^n f(x)$$

But this annoys me. It is abuse of notation and makes no sense, as the end index $$n$$ has no associated running index like $$i = 1$$ defined below the summation symbol. Is there an exact way to denote this or can I rely on the reader to understand what this notational hack is supposed to mean from the context, where I talk about the formula?

First use some notation to define your sample. Let $$X_1, X_2,\ldots,X_n$$ be the $$n$$ members in your sample. If $$f$$ is the function you're applying to each member, then the sum you are looking for can be written $$\sum_{i=1}^n f(X_i)$$.
If you have a different set of $$X$$'s within each outer iteration, then you could modify your notation: $$X_{1,1}, X_{1,2},\ldots,X_{1,n}$$ are the items in iteration 1, then $$X_{2,1}, X_{2,2},\ldots,X_{2,n}$$ are the items on iteration 2, and so on. The overall sum would then be written $$\sum_{k=1}^N\sum_{i=1}^n f(X_{k,i})$$.
• Hm, that would work for how I described the problem, yes. But actually that is not flexible enough. I cannot define $X_i$ as global variables, as the sum actually occurs in the scope of another sum, and each iteration of the outer sum the inner sum samples again. I did not think of mentioning that complication, sorry. – user3578468 Aug 5 at 22:59