We recently finished talking about how to transform a random variable by shifting it or scaling it by
some constant.
But now we want to talk about how to combine multiple random variables together.
It's a similar concept in the sense that we are applying a kind of transformation to the random variables
by combining them, but instead of applying a simple shift or scale to one random variable, here we
have two different random variables, and we're combining them together as either a sum or a difference.
And this has all kinds of real world applications.
If we know how to do this, we can save ourselves some time, especially if we already have particular
statistics about the individual random variables.
So what we're saying here, let's go through an example as we do this so we can see what's actually
going on.
Let's say that we work for a company and we're trying to get an understanding of the total time that
it takes for our company to get our employees paid.
And we realize that what we really have here is two random variables.
We have a set of data about how long it takes the manager of each department to approve the time cards
of the timesheets of our employees.
And then we have a separate set of data about how long it takes our payroll department to process those
approved time cards or timesheets.
But let's say that these two activities in total constitute all of the time that the company spends
to actually get over the finish line of issuing paychecks to our employees.
What we want to do is think about this set of data as the random variable x and this set of data as
the random variable Y.
Of course, in this particular example, what we're interested in is a sum of these two totally separate
random variables because we want to know the total time.
If we add these together, the total time it takes our company to pay employees, which means we're
going to be looking here, of course, at the sum of two random variables instead of difference.
Now, before we go forward with actually talking about the math of these calculations, the first thing
we want to say is that it's important that our two variables be independent of one another.
And the reason for that is because our standard deviation value, the standard deviation of the sum
is only going to make sense when we have independent variables.
So these two data sets can't be affected by one another.
But if we're confident that these two random variables X and Y are independent of each other, then
we can find their combination and calculate a mean variance and standard deviation for that combination.
We also want to say that it's important that our two different random variables have matching units
or units that make sense together.
For example, if our first random variable is given in units of ours and our second random variable
is given in units of square meters, so we have a measure of time and a measure of area doesn't really
make sense to add those two things together or to find their difference.
It's nonsensical to think about adding time to some area measurement that's probably obvious, but we
just want to make sure that our units are matching.
So if our random variable X here is in ours, we want to make sure that our random variable Y is also
an hour so we can get total hours.
And of course if we were given two different data sets and maybe the first one is in terms of hours
and the second one is in terms of minutes, we would want to convert the second data set from minutes
to hours or the first data set from hours to minutes so that we have matching units and it makes sense
to add the two together or to find their difference.
But assuming that we have independence and that our units are matching, let's go ahead now and talk
about the idea of combining these two random variables.
Before we do that, let's look at the data sets individually, starting with the mean of each data set.
We're going to say for now that this is the entire population of data instead of a sample, which means
that the mean is going to be given by the sum of these hourly values here.
One plus two is three, plus two is five, plus three is eight.
Eight divided by the number of data points, four is two.
So we have a mean of eight over four or two.
And then over here we'll say this is the mean with respect to the variable X, and then over here,
the mean of the variable Y here will be two plus three is five, plus five is ten, plus six is 16.
So we have 16 divided by four or four.
So what we're saying is that maybe our company has four departments in total and the manager of the
first department takes one hour to approve timesheets, the manager, the second department takes 2
hours, the manager of the third department takes 2 hours, and the manager of the fourth department
takes 3 hours.
To approve timesheets.
And then our payroll team takes 2 hours, 3 hours, 5 hours and 6 hours to process payroll for departments
one, two, three and four, respectively.
So we can say that on average, managers take 2 hours to approve timesheets and on average payroll takes
4 hours to process payroll for each department.
So we have a mean for each random variable.
And then of course, we could also calculate variance.
So our variance calculation, remember, we take each data point and subtract the mean.
So here we start with this data point of one.
So we say one minus two.
We square that value and then we add to that the same calculation for all of the other departments.
So here we get two minus two quantity squared plus two minus two quantity squared plus three minus two
quantity squared.
And we divide this whole thing by the number of data points that we have four and we'll divide by four
because we're going to say that this data represents the entire population of our departments.
If this was a sample of a larger number of departments in our company, we would divide by n minus one
or in this case four, minus one or three.
So we'd be dividing by three instead of by four.
But since we're going to say that this represents population, data will divide by n the total number
of departments here.
So the result then is one fourth, one minus two is negative, one quantity squared is a positive one.
So we have one here.
This will be zero zero and then three minus two is one, quantity squared is one.
So we get two divided by four or.
One half.
So our variance then.
Is one half.
And then standard deviation is the square root of that or one over square root two.
If we do a variance in standard deviation calculation for the variable y, we start with each data point,
subtract the mean, so we get two minus four quantity squared plus three minus four.
Quantity squared plus.
Five minus four squared.
And then finally the last data point six minus four quantity squared.
And then again, we're doing a population calculation, assuming that this is the entire population.
So we divide by the number of data points, which is four, or multiply that by one fourth.
And if we simplify here, we get one fourth and then we'll get two.
Minus four is negative two, quantity squared is positive, four, three minus four is negative, one
quantity squared is one, five, minus four is one squared is one and six minus four is two squared
is four.
And so we get four plus one plus one plus four is ten.
Ten divided by four is five halves or two and one half.
So we can say then that the variance of Y is five halves, which means that the standard deviation of
Y is the square root of that, or the square root of five halves, the square root of two and one half.
Now, here's what the idea of combining random variables really comes in handy.
Let's say that we've already been collecting this data about the amount of time that our managers spend
approving timesheets and the amount of time that our payroll team spends processing payroll for each
department.
So assuming we already have all of this information, if we now want to calculate the sum or difference
of these two data sets, we don't have to start over from this raw data and create a whole new data
set for the sum or the difference and then go through the process again of calculating mean variance
and standard deviation for the new dataset.
If we already have these summary statistics, then we can go directly to these formulas and use them
to find the sum or difference of the two variables.
So for instance, we can see here that the mean of the sum is equal to the sum of the means.
In other words, to find the mean of the sum, we simply add the two means together to plus four and
we get 6 hours, which means that total payroll processing time between the managers and the payroll
department, if we add up all that data together, our mean is 6 hours per department.
And similarly, if we wanted to find the difference, the mean of the difference, we would simply take
the difference of the means.
So we could take four minus two.
To get to.
And we could say that on average, the payroll department spends 2 hours extra per department than the
manager spend per department.
On the process of getting the employees paid.
Realize here that there are a few different ways that we can prove this to ourselves, one of which
being that we can actually create a new data set.
We'll call it the some data set, and we find the new data set for the some by adding data points from
these original data sets, X and Y.
So if we take one plus two, we get the new data point three in the data set for the sum.
If we take two plus three, we get five, two plus five, we get seven and three plus six, we get nine.
This is now a new data set where we've summed the data points in sets X and Y.
And what we realize here is that if we take the mean of this new data set, we would add 3 to 5 to get
eight plus seven is 15, plus nine is 24.
We get 24 divided by the number of data points in the population for 24 divided by four is six and we
see that we get back to this value.
We already found same thing here.
If we create a new data set for the difference, we'll say a new data set.
Four.
The difference if we take two minus one, we get one, three minus two, we get one five minus two,
we get three and six minus three, we get three.
Now we have a new data set for the difference.
And if we take the mean here, we get one plus one is two, plus three is five, plus three is eight,
eight divided by four is two.
And we get back to the mean for the difference that we already found.
Now, in the same way, if we want to make a variance calculation for the sum or the difference of X
and Y, we don't have to build this new data set for the sum and then start fresh with a variance calculation.
For this new data set.
We don't have to find the data set for the difference and then start fresh with a variance calculation
for this data set for the difference.
Instead, we can use the fact that we already have variance values for both X and Y and use these formulas
here to calculate variance.
So the variance for the sum is equal to the sum of the variances.
So we take one half plus five halves is six over two or three, so we get a variance of three.
And then similarly here for the variance of the difference, to find the variance for the difference,
we take the sum of the variances.
So again we get three.
Now while we're here, it's important to mention what we just said here, the variance formula that
we used to find the variance for the sum and the variance for the difference was identical.
When we find the variance for the sum, we add the variances.
And you would think that when we find the variance for the difference, we take the difference of the
variances like we did up here with the formulas for the mean, but instead we find the sum of the variances
again.
And that's because both data sets bring their own variances to the table.
And even when we combine them into a new data set for the sum or a new data set for the difference,
we're not eliminating any of the spread of the data set when we do that.
And so the variance for the new data set, whether we're finding the sum or the difference as our combination,
the variance is still going to be found by summing the two variances from the original data sets X and
Y, which means then of course, that our standard deviations for both the sum and difference are also
going to be the same.
The standard deviations will be, of course, the square root of the variance.
So the standard deviation of the sum will be square root 3 hours and the standard deviation of the difference
will be square root 3 hours.
Keep in mind also that it's invalid for us to find the standard deviation of the sum or difference directly.
In other words, notice here in our table of formulas that we are combining the means and the variances,
but we don't have formulas for the standard deviation, and that's because we can't find the standard
deviation of the sum by summing the standard deviations.
And we can't find the standard deviation of the difference by summing the standard deviations or taking
the difference of the standard deviations.
The only way to get to standard deviation for the combination is to first find the variance of the combination
by summing the variances of the original data sets and then to take the square root of variance in order
to get standard deviation.
So the whole takeaway here is that if we find ourselves in a scenario where we already have summary
statistics like these ones, we've been maybe tracking this information across two data sets, X and
Y.
So in this case we've been keeping track of how many hours it takes managers to approve timesheets for
each department, and we've been keeping track of how many hours it takes our payroll team to process
payroll for each department, such that we already have a mean variance and standard deviation value
for both of these independent random variables X and Y.
Then when we want to find the sum or difference of these two variables, when we want to find the combination,
what we realize is that we do not have to start from the beginning and combine these two data sets into
a new data set for the sum or a new data set for the difference and start completely from scratch with
a mean variance and standard deviation calculation for this new data set or this new data set.
Instead, if we already have this information, we can go straight to these formulas and immediately
and directly make these calculations here to see the mean variance in standard deviation of both the
sum of these random variables and the difference of these random variables, which just means that we
want to keep in mind that when we already have this information, we can move quickly to the combination
and save ourselves a lot of time.
Redoing the math from scratch with a new combined data set.
And of course that can be really helpful when we're trying to answer real world question.
Like the one we were here where we were trying to get a total for the complete number of hours spent
across our entire company collecting all departments together in order to get payroll processed from
beginning to end.
Or the difference between these two departments on the amount of time spent on payroll.