If the variables that are analyzed are dependent, i.e. their values affect each other, we sometimes need information about their dependency. A useful measure is the correlationcoefficient, that is determined from the covariance of two variables. The square of the correlation coefficient tells us what proportion of the variation of the y values can be attributed to a linear relationship with the x values. If the variables are independent (or uncorrelated) the covariance and correlation coefficient are equal to 0.
The methods assume that the samples of the two histograms are written to a file. If we have a simulation that exhibits queue swapping we could determine the correlation of the sizes of the queues as follows :
q1 -> reportsize(h1); // add reports q2 -> reportsize(h2); h1 -> file("sizes1"); // raw samples h2 -> file("sizes2"); sim -> run(10000.0); analysis* a -> covariance(h2); // covariance h1 and h2 a -> correlation(h2); // correlation h1 and h2