public override IDistribution Fit(double[][] observations, double[] weights)
{
#if DEBUG
for (int i = 0; i < weights.Length; i++)
if (Double.IsNaN(weights[i]) || Double.IsInfinity(weights[i]))
throw new Exception("Invalid numbers in the weight vector.");
#endif
// Compute weighted mean vector
double[] means = Tools.Mean(observations, weights);
// Compute weighted covariance matrix
double[,] cov = Tools.Covariance(observations, means, weights);
// return the newly fitted distribution.
return new NormalDistribution(means, cov);
}