/// <summary>
        /// Returns the probability distribution function.
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public double ProbabilityDistributionFunction(double x)
        {
            if (x <= 0.0)
            {
                throw new ArgumentException();
            }
            double logGamma = Fun.LogGamma(freedom / 2.0);

            return(System.Math.Exp((freedom / 2.0 - 1.0) * System.Math.Log(x / 2.0) - x / 2.0 - logGamma) / 2.0);
        }
Exemple #2
0
        /// <summary>
        /// Sets the distribution parameter.
        /// </summary>
        /// <param name="freedom">degrees of freedom.</param>
        /// <exception cref="ArgumentException">if <i>freedom &lt;= 0.0</i>.</exception>
        public void SetState(double freedom)
        {
            if (freedom <= 0.0)
            {
                throw new ArgumentException();
            }
            this.freedom = freedom;

            double val = Fun.LogGamma((freedom + 1) / 2) - Fun.LogGamma(freedom / 2);

            this.TERM = System.Math.Exp(val) / System.Math.Sqrt(System.Math.PI * freedom);
        }
Exemple #3
0
        /// <summary>
        /// Returns the probability distribution function.
        /// </summary>
        public double pdf(double x)
        {
            if (x < 0)
            {
                throw new ArgumentException();
            }
            if (x == 0)
            {
                if (alpha == 1.0)
                {
                    return(1.0 / lambda);
                }
                else
                {
                    return(0.0);
                }
            }
            if (alpha == 1.0)
            {
                return(System.Math.Exp(-x / lambda) / lambda);
            }

            return(System.Math.Exp((alpha - 1.0) * System.Math.Log(x / lambda) - x / lambda - Fun.LogGamma(alpha)) / lambda);
        }