def _calculate_log_likelihood(self):
        #if self.m == None:
        #    Give error message
        R = zeros((self.n, self.n))
        X, Y = array(self.X), array(self.Y)
        thetas = 10.**self.thetas

        #weighted distance formula
        for i in range(self.n):
            R[i, i+1:self.n] = e**(-sum(thetas*(X[i] - X[i+1:self.n])**2., 1))

        R = R*(1.0 - self.nugget)
        R = R + R.T + eye(self.n)
        self.R = R

        one = ones(self.n)
        try:
            self.R_fact = cho_factor(R)
            rhs = vstack([Y, one]).T
            R_fact = (self.R_fact[0].T, not self.R_fact[1])
            cho = cho_solve(R_fact, rhs).T

            self.mu = dot(one, cho[0])/dot(one, cho[1])
            ymdotone = Y - dot(one, self.mu)
            self.sig2 = dot(ymdotone, cho_solve(self.R_fact,
                                                (ymdotone)))/self.n
            #self.log_likelihood = -self.n/2.*log(self.sig2)-1./2.*log(abs(det(self.R)+1.e-16))-sum(thetas)
            self.log_likelihood = -self.n/2.*log(self.sig2) - \
                                  1./2.*log(abs(det(self.R) + 1.e-16))

        except (linalg.LinAlgError, __HOLE__):
            #------LSTSQ---------
            self.R_fact = None  # reset this to none, so we know not to use cholesky
            # self.R = self.R+diag([10e-6]*self.n)  # improve conditioning[Booker et al., 1999]
            rhs = vstack([Y, one]).T
            lsq = lstsq(self.R.T, rhs)[0].T
            self.mu = dot(one, lsq[0])/dot(one, lsq[1])
            ymdotone = Y - dot(one, self.mu)
            self.sig2 = dot(ymdotone, lstsq(self.R, ymdotone)[0])/self.n
            self.log_likelihood = -self.n/2.*log(self.sig2) - \
                                   1./2.*log(abs(det(self.R) + 1.e-16))
            #print self.log_likelihood
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/surrogatemodels/kriging_surrogate.py/KrigingSurrogate._calculate_log_likelihood