# How to estimate a percentile of a sum of two independent distributions

I have two independent distributions (Distr-1 and Distr-2) these distributions represent service times of two systems and sampled at run time. Basically, I have two servers in a chain, one after another, application's requests go through server 1 and then through server 2. Each server maintains its own distribution of its own service times.

My question is: By knowing the individual distributions, how can I estimate/compute a target percentile (say 90th) of the sum of these two distributions? Conceptually this is equivalent if I would record delays from the moment request enters the first server until the moment it leaves the second server (ignoring the network delay) and then I would plot the CDF of these delays for all requests.

My initial approach was to compute the 90th percentiles of both Distr-1 and Distr-2 and then sum them up together to obtain the 90th percentile of the Distr-(1+2). But soon I realized that this is not correct. I am attaching a sample plot, I know blue and red distributions and I want to obtain 90th percentile of the green one. However, I can not simply add 90th percentiles of the blue and red to obtain 90th of the green one.

Since the two input percentiles obtained at run time, I do not know if they comply to some known distributions (e.g., normal or exponential etc.) thus I have only their numerical representations (as a list of samples).

Would you have any recommendations of how I could solve this problem?

Thanks!

• Just to clarify. You have two random variables that are independent from one another and what you want to know is the distribution of their sum. The reason that you want to know this is that you want to compute the 90th percentile of their sum?
– user31790
Commented May 20, 2017 at 10:06
• Yes, that is correct, however, I would like to be able to compute any percentiles, for example, 95th or 99th etc. Commented May 20, 2017 at 11:28
• Why would the service times be independent? wouldn't they depend on the characteristics of whatever they were serving and hence be dependent? Commented May 20, 2017 at 16:38

As I understand the question you have two random variables that are independent from one another and what you want to know is the distribution of their sum. The reason that you want to know this is that you want to compute the percentile.

There are as far as I can tell two solutions to your problem.

I. What you have are two independent gamma distributed random variables. The gamma distribution is used to model waiting times and this seems to be applicable to your problem here. What you can do is to fit the two gamma distributions to the data. For the distribution of their sum you can then go here.

II. What you have are two independent random variables and their empirical distributions. What you can do therefore is to fit the empirical cdf of both and use this to draw 100,000 - 1000,000 random variables from from each and add these together. The empirical distribution of their sum should be close to the distribution of their sum.

Once you have the distribution then you can use the inverse CDF to find the percentiles.

• I have a question regarding the approach #1. Is there an easy way to know which distribution should I use (e.g., gamma, normal, pareto, etc.) to be able to find an analytical solution? It is quite possible that the shape the distributions might vary from server to server. I presume if I can not fit any known distributions I will rely on approach #2? Thanks! Commented May 20, 2017 at 13:16
• @kirbo There's no "easy" way to know which distribution you have. In general you never know, though you can often eliminate many possibilities, there's always an infinite number of others you can't rule out. Real data tend not to actually follow simple distributional models except as a rough approximation. Commented May 20, 2017 at 16:41

@kirbo - we are using Monte-Carlo simulation (sampling from the defined input distribtions, vector-based application of the target function and characterisation of the evaluated outcome distribution) under assumption of independence. This works for any distribution family and target function. In case of heavy-tailed input distributions you would need a large sample or apply some form of interval sampling (e.g. latin hypercube). Cheers, Matthias