public Fit ( double observations, double weights ) : IDistribution | ||
observations | double | /// The array of observations to fit the model against. /// |
weights | double | /// The weight vector containing the weight for each of the samples. /// |
Résultat | IDistribution |
/// <summary> /// Estimates a new Normal distribution from a given set of observations. /// </summary> /// public static NormalDistribution Estimate(double[] observations, double[] weights, NormalOptions options) { NormalDistribution n = new NormalDistribution(); n.Fit(observations, weights, options); return(n); }
public void FitTest2() { NormalDistribution target; target = new NormalDistribution(); double[] observations = { 1, 1, 1, 1 }; bool thrown = false; try { target.Fit(observations); } catch (ArgumentException) { thrown = true; } Assert.IsTrue(thrown); }
public void FitTest() { double expectedMean = 1.125; double expectedSigma = 1.01775897605147; NormalDistribution target; target = new NormalDistribution(); double[] observations = { 0.10, 0.40, 2.00, 2.00 }; double[] weights = { 0.25, 0.25, 0.25, 0.25 }; target.Fit(observations, weights); Assert.AreEqual(expectedMean, target.Mean); Assert.AreEqual(expectedSigma, target.StandardDeviation, 1e-6); target = new NormalDistribution(); double[] observations2 = { 0.10, 0.10, 0.40, 2.00 }; double[] weights2 = { 0.125, 0.125, 0.25, 0.50 }; target.Fit(observations2, weights2); Assert.AreEqual(expectedMean, target.Mean); // Assert.AreEqual(expectedSigma, target.StandardDeviation, 1e-6); }
/// <summary> /// Estimates a new Normal distribution from a given set of observations. /// </summary> /// public static NormalDistribution Estimate(double[] observations, double[] weights, NormalOptions options) { NormalDistribution n = new NormalDistribution(); n.Fit(observations, weights, options); return n; }