public void FitTest() { UniformContinuousDistribution target = new UniformContinuousDistribution(); double[] observations = { -1, 2, 5, 2, 3, 1, 4 }; double[] weights = null; target.Fit(observations, weights); Assert.AreEqual(-1.0, target.Minimum); Assert.AreEqual(5.0, target.Maximum); }
public FuncionUniforme(double[] eventos) : base(eventos) { try { DistribucionContinua = new UniformContinuousDistribution(); DistribucionContinua.Fit(eventos); A = ((UniformContinuousDistribution)DistribucionContinua).Minimum.ToString("0.0000"); B = ((UniformContinuousDistribution)DistribucionContinua).Maximum.ToString("0.0000"); Resultado = new ResultadoAjuste(StringFDP, StringInversa, DistribucionContinua.StandardDeviation, DistribucionContinua.Mean, DistribucionContinua.Variance, this); } catch (Exception) { Resultado = null; } }
public void GenerateTest() { UniformContinuousDistribution target = new UniformContinuousDistribution(0, 2); double[] samples = target.Generate(1000000); for (int i = 0; i < samples.Length; i++) { Assert.IsTrue(samples[i] >= 0); Assert.IsTrue(samples[i] <= 2); } UniformContinuousDistribution newTarget = new UniformContinuousDistribution(); newTarget.Fit(samples); Assert.AreEqual(0, newTarget.Minimum, 1e-5); Assert.AreEqual(2, newTarget.Maximum, 1e-5); }
public void GenerateTest2() { UniformContinuousDistribution target = new UniformContinuousDistribution(0, 2); double[] samples = new double[1000000]; for (int i = 0; i < samples.Length; i++) { samples[i] = target.Generate(); Assert.IsTrue(samples[i] >= 0); Assert.IsTrue(samples[i] <= 2); } UniformContinuousDistribution newTarget = new UniformContinuousDistribution(); newTarget.Fit(samples); Assert.AreEqual(0, newTarget.Minimum, 1e-5); Assert.AreEqual(2, newTarget.Maximum, 1e-5); }