--------
float : Value of the distribution at X
if not isinstance(X, np.matrix):
if isinstance(X, (np.ndarray, list, tuple, set, frozenset)):
X = np.matrix(X)
X = np.reshape(X, (1, len(X)))
else:
raise TypeError("mean_vec should be a 1d array type object")
X = np.reshape(X, (len(X), 1))
sub_vec = X - self.mean_vec
n = len(sub_vec)
return float(np.exp(-0.5 * sub_vec.transpose() * self.precision_matrix * sub_vec) /
(2 * np.pi) ** (n * 0.5) * np.linalg.det(self.cov_matrix) ** 0.5)
After Change
--------
float : Value of the distribution at X
if isinstance(X, (np.matrix, np.ndarray, list, tuple, set, frozenset)):
X = np.array(X).flatten()
X = np.matrix(np.reshape(X, (len(X), 1)))
else:
raise TypeError("X should be a 1d array type object")
sub_vec = X - self.mean_vec
n = len(sub_vec)