# How to find a top iOS developer in New York?

Know what you want. Know what your app is and be able to explain it so that anyone can understand. Determine if you need an app that has social media integration if there will be advertising… # Understanding Transformation of Random Variables using Python

A random variable is a numerical description of the outcome of a statistical experiment. It can be discrete or continuous depending upon the outcome of experiment.

We would be looking at two kinds of transformations of random variables namely ‘Scaling’ and ‘Shifting’.

SHIFTING TRANSFORMATION

Let ‘P’ be a random variable and ‘Q’ be the transformed random variable where Q= P+ t (t is any real number). Let us look at one particular case where Q= P+ 8. We plot the random variables on x-axis and a set of 100 values equally spaced between 1 and 10 on y-axis.

From the above scatter plot, we observe that mean of ‘P’ has shifted to the right by 8 units after ‘shifting transformation’. Let us verify this by calculating the mean difference between ‘P’ and ‘Q’.

As expected the mean difference between ‘P’ and ‘Q’ is 8 units. Hence shifting a random variable by ‘t’ units also shifts the mean of random variable by ‘t’ units. E[P+t] = E[P] + t where E[P] is expected value of P which is same as mean value of ‘P’.

Now let us look at what shifting does to Variance of random variable. Variance gives you a measure of distribution of points about the mean. It is the average of the squared distances from each point to the mean. A high value of Variance indicates the points lie far away from mean. A low value of Variance indicates the points lie closer to mean. If you observe the previous scatter plot, we see that blue and yellow points are distributed about their respective means in a similar fashion. So we would expect the Variance to remain same after ‘shifting transformation’. Let us verify this by calculating the variance difference between ‘X’ and ‘Y’.

As expected the variance difference between random variables ‘P’ and ‘Q’ is 0 units. Hence shifting a random variable by ‘t’ units does not affect the variance of random variable. Var[P+t] = Var[P] where Var[P] is Variance of random variable ‘P’.

SCALING TRANSFORMATION

Let ‘P’ be a random variable and ‘Q’ be the transformed random variable where Q= t*P (t is any real number). Let us look at one particular case where Q= 8*P. We plot the random variables on x-axis and a set of 100 values equally spaced between 1 and 10 on y-axis.

From the above scatter plot, we observe that mean value of ‘P’ has become 8 times its previous mean value after ‘scaling transformation’. Let us verify this by the code given below.

As expected mean value of ‘P’ has become 8 times its previous mean value after ‘scaling transformation’. Hence scaling a random variable by ‘t’ units also scales the mean of random variable by ‘t’ units. E[t*P] = E[P]*t .

Now let us look at what scaling does to Variance of random variable. If you observe the previous scatter plot, we see that the yellow points are distributed far away from mean than the red points indicating that Variance of ‘P’ has increased significantly after scaling transformation. Let us verify this by the code given below.

As expected Variance of ‘Q’ = 64 times Variance of ‘P’. Hence scaling a random variable by ‘t’ units scales the variance of random variable by ‘t²’ units. Var[t*P] = Var[P]*t² where Var[P] is Variance of ‘P’.

SHIFTING & SCALING TRANSFORMATION

Let us see what happens when a random variable is both scaled and shifted. Let ‘P’ be a random variable and ‘Q’ be the transformed random variable where Q= n*P+ t (n and t are real numbers). Let us look at one particular case where Q= 10*P+ 8. We plot the random variables on x-axis and a set of 100 values equally spaced between 1 and 10 on y-axis.

From the scatter plot we observe both the mean and variance of random variable ‘P’ has increased.

First we apply the ‘scaling’ transformation and then the ‘shifting’ transformation to the random variable ‘P’. The mean is scaled by 10 units and then shifted by 8 units. The variance is scaled by 100 units.

## Related posts:

### How much exactly does your phone exposes you to App developers?

In 1969 Apollo 13 arrived at moon the man for the first time walked on the moon all the great planning and engineering behind it was all performed with the help of a simple computer; Apollo guidance…

### The Orchestrated Wonder of Your Microbiome

When I have the chance to listen to a full orchestra, I appreciate the fact that there are so many musicians playing different instruments, bringing out particular notes at the right tempo, with…

### Snapchat is launching a mentorship and funding program for 25 Black creators

Twenty-five Black Snapchat creators will receive funding, mentorship, and other resources through a one-year accelerator program, the company announced today. The program follows similar efforts at…