예제 #1
0
        /// <summary>
        /// Samples an inverse Wishart distributed random variable by sampling
        /// a Wishart random variable and inverting the matrix.
        /// </summary>
        /// <param name="rnd">The random number generator to use.</param>
        /// <param name="degreesOfFreedom">The degree of freedom (ν) for the inverse Wishart distribution.</param>
        /// <param name="scale">The scale matrix (Ψ) for the inverse Wishart distribution.</param>
        /// <returns>a sample from the distribution.</returns>
        public static Matrix <double> Sample(System.Random rnd, double degreesOfFreedom, Matrix <double> scale)
        {
            if (Control.CheckDistributionParameters && !IsValidParameterSet(degreesOfFreedom, scale))
            {
                throw new ArgumentException(Resources.InvalidDistributionParameters);
            }

            var r = Wishart.Sample(rnd, degreesOfFreedom, scale.Inverse());

            return(r.Inverse());
        }
예제 #2
0
        /// <summary>
        /// Samples an inverse Wishart distributed random variable by sampling
        /// a Wishart random variable and inverting the matrix.
        /// </summary>
        /// <param name="rnd">The random number generator to use.</param>
        /// <param name="nu">The degrees of freedom.</param>
        /// <param name="s">The scale matrix.</param>
        /// <returns>a sample from the distribution.</returns>
        public static Matrix <double> Sample(Random rnd, double nu, Matrix <double> s)
        {
            if (Control.CheckDistributionParameters && !IsValidParameterSet(nu, s))
            {
                throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters);
            }

            var r = Wishart.Sample(rnd, nu, s.Inverse());

            return(r.Inverse());
        }