# How can I calculate the expected value of the sum of “n” i.i.d. variables with any distribution?

Particulary, I would like to find the expected value of the sum of $$n$$ variables distributed like ParetoDistribution[1,1.14]. For example, this works for the sum of two vars with Gamma distribution:

dist = GammaDistribution[1, 1];
c[n_] := Integrate[
InverseFourierTransform[(CharacteristicFunction[dist, t])^n, t, x]*x,
{x, -∞, ∞}]
c[2]


I've tried this and it works for almost every distribution but I think that this is not a very efficent way of doing it and still doesn't work for the Pareto.

My ultimate goal is to Plot what I've called c[n] against n, to see how the expected value of the sum of n iid variables changes with n.

I need it to do it in a Monte Carlo way, in the sense that I need to simulate each variable as a random variable but with the same underlying distribution. If I calculate the mean for a Pareto(1,1.14) I get 8.14 but It is very uncommon that I'll get that value from a sample. So the sample mean of 2 variables is likely to be under 2*8.14. I need to capture that randomness.

• I'm not sure what you mean by "I need to capture that randomness". If independent and identically distributed (i.i.d) random variables $X_i$ ($i=1,2,\ldots,n$) all have mean $\mu$, then the mean of the sum is simply $n\mu$. No need for Monte Carlo. – JimB Jul 12 '19 at 14:57
• I need sample mean of a simulated sample. – Juan Carlos Herranz Ramos Jul 12 '19 at 15:00
• Firs figure of arxiv.org/pdf/1802.05495.pdf – Juan Carlos Herranz Ramos Jul 12 '19 at 15:01
• I read the paper a bit. that figure shows a measure of the extent of that fat tail to the sum of random numbers on the vertical axis. It's not just taking the union of n- random variables. OP does not write that expression. If you are interested in the results, please at least write formulas. – Xminer Jul 12 '19 at 15:15
• Please re-write your question and title to deal explicitly with either the expectation of the mean deviation or the $\kappa$ metric and include the reference article in the body of the question. I understand that you're new to this forum but you need to fix the question and title so the folks here don't spend time answering questions that won't help you. – JimB Jul 12 '19 at 17:15

This? my code sampled $$n$$ pairs, take its MeanDeviation,then get Expected Value. I do not know the detailed procedure, but it would be reference.

ClearAll[dist];
fatTailMeasure :=
Function[{n, dist},
SeedRandom[
1234]; (MeanDeviation /@ Partition[#, n] &@
RandomVariate[dist, 1000000]) // Mean]
Function[{dst},
fatTailMeasure[#, dst] & /@ Range[1, 10]] /@ {CauchyDistribution[],
ParetoDistribution[1, 1.14], , StudentTDistribution[3],
NormalDistribution[]} // ListLinePlot


• Thank you for your answer. I've realized that I haven't made an important point. I need it to do it in a Monte Carlo way, in the sense that I need to simulate each variable as a random variable but with the same underlying distribution. If I calculate the mean for a Pareto(1,1.14) I get 8.14 but It is very uncommon that I'll get that value from a sample. So the sample mean of 2 variables is likely to be under 2*8.14. I need to capture that randomness. – Juan Carlos Herranz Ramos Jul 12 '19 at 14:44
• aww,please write it in the question... – Xminer Jul 12 '19 at 14:49
• What you mean is something like this?Histogram[ Total /@ Partition[#, 2] &@ RandomVariate[ParetoDistribution[1, 1.14], 1000]] – Xminer Jul 12 '19 at 14:50
• arxiv.org/pdf/1802.05495.pdf – Juan Carlos Herranz Ramos Jul 12 '19 at 14:54
• I've found this. First figure. – Juan Carlos Herranz Ramos Jul 12 '19 at 14:54

For the Gamma distribution:

dist = GammaDistribution[1, 1];
With[{n = 5},
vars = Table[Unique[], n];
dd = TransformedDistribution[Total[vars], Thread[vars \[Distributed] dist]]]


For the Pareto distribution it's a bit less obvious:

dist = ParetoDistribution[1, 1.14];
With[{n = 2},
vars = Table[Unique[], n];
dd = TransformedDistribution[Total[vars], Thread[vars \[Distributed] dist]]]
(*    complicated output that is not any simpler than what we put in    *)


We can, however, calculate properties of dd:

Mean[dd]
(*    16.2857    *)

PDF[dd]
(*    complicated hypergeometric formula    *)


The expectation is linear, so just use the fact that $$E\left(\sum_i X_i\right)=\sum_i E\left(X_i\right)$$ I assume you know how to take the expectation of random variables using Mean[dist].

Independence is irrelevant here. If they are iid it simplifies to $$c(n)=E\left(\sum_{i=1}^n X_i\right)=n\,E(X_1),$$ As $$c$$ is linear the plot will be... linear.

dist = ParetoDistribution[1, 1.14]
c[n_Integer] := n Mean@dist
DiscretePlot[c[n], {n, 0, 15}]


If you want to do it with Monte-Carlo mean approximation you can do the following:

MCMean[d_, m_] := Mean[RandomVariate[d, m]];
MCMean[dist, 1000000000]

7.42469


which is not very good in spite of the large sample -- but that is the topic of another question: how to estimate means of Pareto distributions via MC methods.