Beispiel #1
0
 /// <summary>
 /// Returns the value of the probability density function.
 /// </summary>
 /// <param name="x">Value</param>
 /// <returns>float precision floating point number</returns>
 public float Function(float x)
 {
     if (x < 0)
     {
         return(0);
     }
     return((float)Math.Pow(x, k - 1) * (float)Math.Exp(-x / thetta) / (Special.Gamma(k) * (float)Math.Pow(thetta, k)));
 }
Beispiel #2
0
        /// <summary>
        ///   Gets the probability density function (pdf) for
        ///   the χ² distribution evaluated at point <c>x</c>.
        /// </summary>
        /// <remarks>
        /// <para>
        ///   The Probability Density Function (PDF) describes the
        ///   probability that a given value <c>x</c> will occur.</para>
        /// <para>
        ///   References:
        ///   <list type="bullet">
        ///     <item><description>
        ///       <a href="http://www.mathworks.com/access/helpdesk/help/toolbox/stats/chi2pdf.html">
        ///       http://www.mathworks.com/access/helpdesk/help/toolbox/stats/chi2pdf.html</a></description></item>
        ///   </list></para>
        /// </remarks>
        /// <returns>
        ///   The probability of <c>x</c> occurring
        ///   in the current distribution.</returns>
        ///
        public override double ProbabilityDensityFunction(double x)
        {
            double v  = degreesOfFreedom;
            double m1 = System.Math.Pow(x, (v - 2.0) / 2.0);
            double m2 = System.Math.Exp(-x / 2.0);
            double m3 = System.Math.Pow(2, v / 2.0) * Special.Gamma(v / 2.0);

            return((m1 * m2) / m3);
        }
Beispiel #3
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="TDistribution"/> class.
        /// </summary>
        ///
        /// <param name="degreesOfFreedom">The degrees of freedom.</param>
        ///
        public TDistribution(double degreesOfFreedom)
        {
            if (degreesOfFreedom < 1)
            {
                throw new ArgumentOutOfRangeException("degreesOfFreedom");
            }

            this.DegreesOfFreedom = degreesOfFreedom;

            double v = degreesOfFreedom;

            // TODO: Use LogGamma instead.
            this.constant = Special.Gamma((v + 1) / 2.0) / (Math.Sqrt(v * Math.PI) * Special.Gamma(v / 2.0));
        }
        private void init(double shape, double spread)
        {
            double twoMuMu  = 2.0 * Math.Pow(shape, shape);
            double gammaMu  = Special.Gamma(shape);
            double spreadMu = Math.Pow(spread, shape);

            nratio = -shape / spread;
            twoMu1 = 2.0 * shape - 1.0;

            constant = twoMuMu / (gammaMu * spreadMu);

            mean     = null;
            variance = null;
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mu"></param>
        /// <param name="omega"></param>
        private void Initialize(float mu, float omega)
        {
            Mu    = mu;
            Omega = omega;

            float twoMuMu  = 2.0f * (float)Math.Pow(mu, mu);
            float gammaMu  = Special.Gamma(mu);
            float spreadMu = (float)Math.Pow(omega, mu);

            nratio = -mu / omega;
            twoMu1 = 2.0f * mu - 1.0f;

            constant = twoMuMu / (gammaMu * spreadMu);
        }