Exemple #1
0
        /// <summary>
        /// Computes the cumulative distribution (CDF) of the distribution at x, i.e. P(X ≤ x).
        /// </summary>
        /// <param name="x">The location at which to compute the cumulative distribution function.</param>
        /// <param name="alpha">The stability (α) of the distribution. Range: 2 ≥ α > 0.</param>
        /// <param name="beta">The skewness (β) of the distribution. Range: 1 ≥ β ≥ -1.</param>
        /// <param name="scale">The scale (c) of the distribution. Range: c > 0.</param>
        /// <param name="location">The location (μ) of the distribution.</param>
        /// <returns>the cumulative distribution at location <paramref name="x"/>.</returns>
        /// <seealso cref="CumulativeDistribution"/>
        public static double CDF(double alpha, double beta, double scale, double location, double x)
        {
            if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0)
            {
                throw new ArgumentException(Resources.InvalidDistributionParameters);
            }

            if (alpha == 2d)
            {
                return(Normal.CDF(location, Constants.Sqrt2 * scale, x));
            }

            if (alpha == 1d && beta == 0d)
            {
                return(Cauchy.CDF(location, scale, x));
            }

            if (alpha == 0.5d && beta == 1d)
            {
                return(SpecialFunctions.Erfc(System.Math.Sqrt(scale / (2 * (x - location)))));
            }

            throw new NotSupportedException();
        }
Exemple #2
0
        /// <summary>
        /// Computes the log probability density of the distribution (lnPDF) at x, i.e. ln(∂P(X ≤ x)/∂x).
        /// </summary>
        /// <param name="alpha">The stability (α) of the distribution. Range: 2 ≥ α > 0.</param>
        /// <param name="beta">The skewness (β) of the distribution. Range: 1 ≥ β ≥ -1.</param>
        /// <param name="scale">The scale (c) of the distribution. Range: c > 0.</param>
        /// <param name="location">The location (μ) of the distribution.</param>
        /// <param name="x">The location at which to compute the density.</param>
        /// <returns>the log density at <paramref name="x"/>.</returns>
        /// <seealso cref="DensityLn"/>
        public static double PDFLn(double alpha, double beta, double scale, double location, double x)
        {
            if (alpha <= 0.0 || alpha > 2.0 || beta < -1.0 || beta > 1.0 || scale <= 0.0)
            {
                throw new ArgumentException(Resources.InvalidDistributionParameters);
            }

            if (alpha == 2d)
            {
                return(Normal.PDFLn(location, Constants.Sqrt2 * scale, x));
            }

            if (alpha == 1d && beta == 0d)
            {
                return(Cauchy.PDFLn(location, scale, x));
            }

            if (alpha == 0.5d && beta == 1d && x >= location)
            {
                return(System.Math.Log(scale / Constants.Pi2) / 2 - scale / (2 * (x - location)) - 1.5 * System.Math.Log(x - location));
            }

            throw new NotSupportedException();
        }