# Interdependent Co-related Random Numbers

Hello,

I want to have 9 different random numbers (according to 9 Gaussians with 9 pairs of mean,sigma) generated, but they all have to be co-related. i.e., One event gives rise to 9 signals in 9 detectors; but each detector has its own gain and efficiency, hence they have their own gaussian distributions (each with potentially different mean,sigmas). What is the best way to do this?

I want to do something like this:
Double_t pMean[]={10.4, 11., 11.7, 5.6, 5.8, 5.2, 9.4, 6.1, 10.9};
Double_t pSigma[]={0.16, 0.13, 0.16, 0.14, 0.15, 0.14, 0.15, 0.14, 0.16};
gRandom->SetSeed(0);
for(Int_t ii=0; ii<100000; ii++)
{
varX[ii] = gRandom->Gaus(pMean,pSigma);
for(Int_t pp=0; pp<9; pp++)
{
varX[pp][ii] = varX[ii]*pMean[pp]/pMean;
//but the above line will only shift the means and not the sigmas, so I get a distribution with shifted means but same widths
}
}

Thanks!

• Sujeewa

Hi,

for generate different Gaussians with the same random number you can do as following:

``````for(Int_t ii=0; ii<100000; ii++)
{
double z  = gRandom->Gaus(0,1);
for(Int_t pp=0; pp<9; pp++)
{
varX[pp][ii] = z*pSigma[pp]+ pMean[pp];
}
}``````

Lorenzo

Oh yes, thank you Lorenzo!