/// <summary> /// Returns a clone of this estimator. /// </summary> /// <returns></returns> public object Clone() { GaussianEstimator result = new GaussianEstimator(); result.SetTo(this); return(result); }
/// <summary> /// Initialises the parameters from data /// </summary> /// <param name="X">X data - initialises weight variances</param> public void InitialiseFromData(IList <Vector> X) { int ND = X.Count; int NL = X[0].Count; double[] logWeightVariances = new double[NL]; GaussianEstimator[] gex = new GaussianEstimator[NL]; for (int l = 0; l < NL; l++) { gex[l] = new GaussianEstimator(); } for (int d = 0; d < ND; d++) { Vector x = X[d]; for (int l = 0; l < NL; l++) { gex[l].Add(x[l]); } } double dimMult = System.Math.Sqrt((double)NL); for (int l = 0; l < NL; l++) { Gaussian g = gex[l].GetDistribution(new Gaussian()); double length = 0.5 * dimMult * System.Math.Sqrt(g.GetVariance()); // If the variance is zero, set to some nominal value. // This is different from the situation where length // is very small if (length < 0.000000001) { length = 1.0; } double wtSDev = 1.0 / length; logWeightVariances[l] = 2.0 * System.Math.Log(wtSDev); } double logBiasWeightVariance = -System.Math.Log((double)NL); SetupParams(logWeightVariances, logBiasWeightVariance); }
/// <summary> /// Sets the state of this estimator from the specified estimator. /// </summary> /// <param name="value"></param> public void SetTo(GaussianEstimator value) { mva.SetTo(value.mva); }