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.
xunif = DataServer.TUniformDistribution("x1", 3., 4.) # 1
xnorm = DataServer.TNormalDistribution("x2", 0.5, 1.5) # 2
tds = DataServer.TDataServer("tdsSampling", "Demonstration Sampling")
tds.addAttribute(xunif)
tds.addAttribute(xnorm)
# Generate the sampling from the TDataServer object
sampling = Sampler.TSampling(tds, "lhs", 1000)
sampling.setUserCorrelation(xunif, xnorm, 0.90) # 3
sampling.generateSample() # 4
tds.Draw("x2:x1", "", "")
Specification of a correlation
Generating a uniform random variable in [3., 4.]
Generating a gaussian random variable with 0.5 as mean value 1.5 as standard deviation.
Specification of correlation of 0.90 between the two attributes
xunifandxnorm.Generate the sample by calling the
generateSamplemethod inTSampling(respectively thegenerateCorrSamplemethod inTBasicSampling).
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]).
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
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).