逻辑斯谛分布即增长分布,增长分布的分布函数是“增长函数”,亦称“逻辑斯谛函数”(logistic function),故增长分布亦称做“逻辑斯谛分布”。逻辑斯谛分布(logistic distribution)是一种连续型的概率分布,记为L(μ,γ),当时μ=0,γ=1,称为标准的逻辑斯谛分布。
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));
}
}
}