C#, Numerical Calculation - Calculation Method and Source Program of Logistic Distribution

 

The logistic distribution is the growth distribution, and the distribution function of the growth distribution is the "growth function", also known as the "logistic function", so the growth distribution is also called the "logistic distribution". The logistic distribution is a continuous probability distribution, denoted as L(μ,γ), when μ=0, γ=1, it is called the standard logistic distribution.

 

 

 

using System;

namespace Legalsoft.Truffer
{
    public class Logisticdist
    {
        private double mu { get; set; }
        private double sig { get; set; }

        public Logisticdist(double mmu = 0.0, double ssig = 1.0)
        {
            this.mu = mmu;
            this.sig = ssig;
            if (sig <= 0.0)
            {
                throw new Exception("bad sig in Logisticdist");
            }
        }

        public double p(double x)
        {
            double e = Math.Exp(-Math.Abs(1.81379936423421785 * (x - mu) / sig));
            return 1.81379936423421785 * e / (sig * Globals.SQR(1.0 + e));
        }

        public double cdf(double x)
        {
            double e = Math.Exp(-Math.Abs(1.81379936423421785 * (x - mu) / sig));
            if (x >= mu)
            {
                return 1.0 / (1.0 + e);
            }
            else
            {
                return e / (1.0 + e);
            }
        }

        public double invcdf(double p)
        {
            if (p <= 0.0 || p >= 1.0)
            {
                throw new Exception("bad p in Logisticdist");
            }
            return mu + 0.551328895421792049 * sig * Math.Log(p / (1.0 - p));
        }
    }
}
 

Guess you like

Origin blog.csdn.net/beijinghorn/article/details/131894134
Recommended