def mahalanobis_norm(self, dx):
"""return Mahalanobis norm based on the current sample
distribution.
The norm is based on Covariance matrix ``C`` times ``sigma**2``,
and includes ``sigma_vec``. The expected Mahalanobis distance to
the sample mean is about ``sqrt(dimension)``.
Argument
--------
A *genotype* difference `dx`.
Example
-------
>>> import cma, numpy
>>> es = cma.CMAEvolutionStrategy(numpy.ones(10), 1) #doctest: +ELLIPSIS
(5_w,...
>>> xx = numpy.random.randn(2, 10)
>>> d = es.mahalanobis_norm(es.gp.geno(xx[0]-xx[1]))
`d` is the distance "in" the true sample distribution,
sampled points have a typical distance of ``sqrt(2*es.N)``,
where ``es.N`` is the dimension, and an expected distance of
close to ``sqrt(N)`` to the sample mean. In the example,
`d` is the Euclidean distance, because C = I and sigma = 1.
"""
return self.sm.norm(np.asarray(dx) / self.sigma_vec.scaling) / self.sigma
评论列表
文章目录