Adding TRandom to a Gaussian. math question

Hello all, my problem is this,
I have a Gaussian with known mean1 and sigma1.
I want to transform it in to another Gaussian with known mean2 and sigma2.
What should be the mean and the sigma parameters of the TRandom function in ROOT, when I add it to my first Gaussian to transform it in to the second?
I want to do it point by point, so for each point of my first Gaussian i want to add random numbers, using the TRandom function, and the final distribution to be the second Gaussian.
many thanks,

Hi, I am not sure what you want to do from your explanation. The sum of two gaussian functions is not another gaussian. Please also explain what you mean by “point by point”. Do you have many randomly generated points? A histogram or plot? It’s not clear from your question.

Hello Amadio.
There is a theorem explaining exactly this,
the sum of two gaussians (normal distributions) is a gaussian.

If X and Y are independent random variables that are normally distributed (and therefore also jointly so), then their sum is also normally distributed.

In the wikipedia you can find the proof in 4 different ways.

I have normally distributed data points.
For each point I want to add a TRandom in order to transform the distribution and change the mean and the sigma.

for example

for (int i = 0; i < tree->GetEntries(); i++) {
var1 and var2 are sets of data points with known mean and sigma.
so I want to add on var1 the TRandom function in order to match the distribution of var2.
My problem is I am not sure what values i need for mean and sigma, to define the rGen.Gaus(mean,sigma)

Well, I think you are abusing the terminology a bit, a gaussian is a function. What you have is a random variable that has a gaussian distribution. That aside, the article you linked above from Wikipedia has all the answers you are looking for:

That is, the final mean is the sum of the individual means, and the final variance is the sum of the squares, as above.
You just have to compute µ_y and sigma_y such that the final values are what you want.

I am not sure it can work just like that.
This theorem is ok for continuous functions but for data points I am not sure this approach can work.
If I have data points below my mean value and i randomly add points from a normal distribution, it might shift the point too low.
I thought that must be a fixed procedure to follow, I dont believe I am the first who try to do this.

so you think the sigma sould be sqrt(sigma2^2-sigma1^2)
and the mean value the differences of the two? mean2-mean1?
Do you know if anyone else has done what i am trying to do?
and thanks for the answer.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.