3.3.1. Imposing the correlation coefficients

It is possible to set the correlation coefficient by hand, using the setUserCorrelation method of both TSampling and TBasicSampling.

    TUniformDistribution *xunif = new TUniformDistribution("x1", 3., 4.);  // 1
    TNormalDistribution  *xnorm = new TNormalDistribution("x2", 0.5, 1.5);  // 2

    TDataServer * tds = new TDataServer("tdsSampling", "Demonstration Sampling");
    tds->addAttribute(xunif);
    tds->addAttribute(xnorm);

    // Generate the sampling from the TDataServer object
    TSampling *sampling = new TSampling(tds, "lhs", 1000);
    sampling->setUserCorrelation( xunif, xnorm, 0.90);  // 3
    sampling->generateSample();  // 4
    tds->Draw("x2:x1","","");

Specification of a correlation

  1. Generating a uniform random variable in [3., 4.]

  2. Generating a gaussian random variable with 0.5 as mean value 1.5 as standard deviation.

  3. Specification of correlation of 0.90 between the two attributes xunif and xnorm.

  4. Generate the sample by calling the generateSample method in TSampling (respectively the generateCorrSample method in TBasicSampling).

The coefficient provided is changing the correlation between the two considered attributes (for a more general discussion on this, see [Bla17]). As an example, Figure 3.4 and Figure 3.5 show the design-of-experiments created with the TSampling class, using a normal and uniform distribution, using three different correlation coefficient values: 0, 0.45 and 0.9. The first one is showing the obtained 2D plan and their corresponding projections, while the second one is showing the same information but displaying their rank instead of their values (this is further discussed in [Bla17]).

../../_images/SetCorrelationExample_NotRank.png

Figure 3.4 Tufte plot of the design-of-experiments created using a normal and uniform distribution, with a LHS method with three correlation coefficient: 0, 0.45 and 0.9

../../_images/SetCorrelationExample_Rank.png

Figure 3.5 Tufte plot of the rank of the design-of-experiments created using a normal and uniform distribution, with a LHS method with three correlation coefficient: 0, 0.45 and 0.9

Instead of provided one-by-one the correlation factors, one can provide the correlation matrix using the setCorrelationMatrix method of both TSampling and TBasicSampling. This method ask for a TMatrixD input and it will check that:

  • the dimension is correct : \((n_{X},n_{X})\).

  • the coefficient are all in the range \([-1,1]\)

  • the diagonal term are exactly at one (if not it sets them to this value).