상속: MultivariateContinuousDistribution
예제 #1
0
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        ///
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        ///
        public override object Clone()
        {
            var clone = new VonMisesFisherDistribution(this.Dimension);

            clone.constant = constant;
            clone.mean     = (double[])mean.Clone();
            clone.kappa    = kappa;

            return(clone);
        }
        public void ConstructorTest1()
        {
            // If p=2 the distribution reduces to the von Mises distribution on the circle.

            double kappa = 4.2;
            var vm = new VonMisesDistribution(0, kappa);
            var target = new VonMisesFisherDistribution(new double[] { -1, 0 }, kappa);

            double s = Math.Sqrt(2) / 2;
            double[] mean = target.Mean;

            double a000 = target.ProbabilityDensityFunction(new double[] { +1, +0 });
            double a045 = target.ProbabilityDensityFunction(new double[] { +s, +s });
            double a090 = target.ProbabilityDensityFunction(new double[] { +0, +1 });
            double a135 = target.ProbabilityDensityFunction(new double[] { -s, +s });
            double a180 = target.ProbabilityDensityFunction(new double[] { -1, +0 });
            double a225 = target.ProbabilityDensityFunction(new double[] { -s, -s });
            double a270 = target.ProbabilityDensityFunction(new double[] { +0, -1 });
            double a315 = target.ProbabilityDensityFunction(new double[] { +s, -s });
            double a360 = target.ProbabilityDensityFunction(new double[] { +1, +0 });

            double offset = -Math.PI;
            double e000 = vm.ProbabilityDensityFunction(offset + 0);
            double e045 = vm.ProbabilityDensityFunction(offset + Math.PI / 4);
            double e090 = vm.ProbabilityDensityFunction(offset + Math.PI / 2);
            double e135 = vm.ProbabilityDensityFunction(offset + Math.PI * (3 / 4.0));
            double e180 = vm.ProbabilityDensityFunction(offset + Math.PI);
            double e225 = vm.ProbabilityDensityFunction(offset + Math.PI * (5 / 4.0));
            double e270 = vm.ProbabilityDensityFunction(offset + Math.PI * (3 / 2.0));
            double e315 = vm.ProbabilityDensityFunction(offset + Math.PI * (7 / 4.0));
            double e360 = vm.ProbabilityDensityFunction(offset + Math.PI * 2);


            Assert.AreEqual(e000, a000, 1e-8);
            Assert.AreEqual(e045, a045, 1e-8);
            Assert.AreEqual(e090, a090, 1e-8);
            Assert.AreEqual(e135, a135, 1e-8);
            Assert.AreEqual(e180, a180, 1e-8);
            Assert.AreEqual(e225, a225, 1e-8);
            Assert.AreEqual(e270, a270, 1e-8);
            Assert.AreEqual(e315, a315, 1e-8);
            Assert.AreEqual(e360, a360, 1e-8);
        }
        /// <summary>
        ///   Creates a new object that is a copy of the current instance.
        /// </summary>
        /// 
        /// <returns>
        ///   A new object that is a copy of this instance.
        /// </returns>
        /// 
        public override object Clone()
        {
            var clone = new VonMisesFisherDistribution(this.Dimension);
            clone.constant = constant;
            clone.mean = (double[])mean.Clone();
            clone.kappa = kappa;

            return clone;
        }