Exemple #1
0
        public void FitTest2()
        {
            double[] observations = { 0.25, 0.12, 0.72, 0.21, 0.62, 0.12, 0.62, 0.12 };

            {
                CauchyDistribution cauchy = new CauchyDistribution();

                cauchy.Fit(observations);

                Assert.AreEqual(0.18784819147980944, cauchy.Location, 1e-6);
                Assert.AreEqual(0.14168064551279669, cauchy.Scale, 1e-6);
                Assert.IsFalse(Double.IsNaN(cauchy.Location));
                Assert.IsFalse(Double.IsNaN(cauchy.Scale));
            }
            {
                CauchyOptions options = new CauchyOptions()
                {
                    EstimateLocation = true,
                    EstimateScale    = false
                };


                CauchyDistribution cauchy = new CauchyDistribution(location: 0, scale: 4.2);

                cauchy.Fit(observations, options);

                Assert.AreEqual(0.34712181102025652, cauchy.Location, 1e-4);
                Assert.AreEqual(4.2, cauchy.Scale, 1e-10);
                Assert.IsFalse(Double.IsNaN(cauchy.Location));
                Assert.IsFalse(Double.IsNaN(cauchy.Scale));
            }
        }
        public void FitTest2()
        {
            double[] observations = { 0.25, 0.12, 0.72, 0.21, 0.62, 0.12, 0.62, 0.12 };

            {
                CauchyDistribution cauchy = new CauchyDistribution();

                cauchy.Fit(observations);

                Assert.AreEqual(0.18383597286086659, cauchy.Location, 1e-10);
                Assert.AreEqual(-0.10530822112775458, cauchy.Scale, 1e-10);
                Assert.IsFalse(Double.IsNaN(cauchy.Location));
                Assert.IsFalse(Double.IsNaN(cauchy.Scale));
            }
            {
                CauchyOptions options = new CauchyOptions()
                {
                    EstimateLocation = true,
                    EstimateScale    = false
                };


                CauchyDistribution cauchy = new CauchyDistribution(location: 0, scale: 4.2);

                cauchy.Fit(observations, options);

                Assert.AreEqual(0.34712181102025652, cauchy.Location, 1e-4);
                Assert.AreEqual(4.2, cauchy.Scale, 1e-10);
                Assert.IsFalse(Double.IsNaN(cauchy.Location));
                Assert.IsFalse(Double.IsNaN(cauchy.Scale));
            }
        }