# Arithmetic operations on Random Variables [closed]

Firstly, I do not have statistics background other than a single lesson I took more than a decade ago, so I will use incorrect terms to explain my question. And probably it is one of the reasons that I cannot find any answers in existing questions. (Or did not understand the answers because they are full of jargon)

### TL;DR version:

I want to find/build an algorithm to perform basic arithmetic operations on multiple random variables (or maybe I should say distributions). But the result should also be a distribution. (For a selected set of possible distributions)

Example:

o X is a random variable with normal distribution,

o Y is a random variable with uniform distribution,

o W is a random variable with normal distribution but limited to a number of sigmas on left, and a different number of sigmas on right,

o Z = X + Y (or X / Y or X - Y / W), what is distribution of Z?

### Long version:

I want to build a library that can do arithmetic operations on Random Variables. And I want it to produce the results as new Random Variables. (I probably should call these distributions) Ideally my library should be able to perform at least 4 basic operations on selected distributions: Uniform, Normal, Normal with restrictions (i.e. for example only the positive values or values in a predefined range) and combination of these

Basic addition looks like doable up to a certain point, but when it comes to multiplication and division, I get lost. Every document I read talks about convolutions, PDFs, CDFs, integrals, summations and many things. But I still could not figure out how to formulate this into a program so it can calculate something like this and give me another distribution:

A=((X+Y)*Z)/(W-Q), where all are random variables with different distributions.

and later, I will be able to do another calculation, this time using A, whatever distribution it has.

For simplicity, I do not want to include the indirect-reference cases. (i.e. what will be the distribution for A*X, given A is already calculated using X. In this case, I assume we will take this new X as a new instance of X generated the same distribution function with the original X. So we will not need to store all distributions used to calculate a result for future reference.

So far, I found that, two normal distributed RVs adds up to another normally distributed RV. 2 uniforms adds to a triangle distribution. What happens when I subtract a normal distribution from a triangle distribution? What happens when I divide them? What happens when I multiply the subtraction result with the division result?

This maybe too complicated to implement as a generic library, at least for me, in that case I want to know how much of it is feasible. And if by chance there is a library which does this, it would be awesome!

Thank you.

## closed as too broad by Michael Chernick, mdewey, Peter Flom♦Jul 20 '18 at 11:29

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

There is already a great deal of existing well-developed theory relating to finding the probability distribution of a function of random variables. As a general problem, you have random variables $(X_1, ..., X_k) \sim \text{Joint Dist}$ and you want to find the distribution of some new random variable:
$$Y = f(X_1, ..., X_k).$$
There are four main methods used to find the distribution of $Y$ in this case. One method is to derive the CDF of $Y$ from the joint distribution of $X_1, ..., X_k$; another is to find the density of $Y$ by direct transformation (useable in some special cases); another is to use Laplace/Fourier transformations (used when you are adding random variables and want to find the distribution of their sum); and finally, the most general method is to use simulation of the random variables to approximate the distribution of $Y$ to a desired level of accuracy.