
using System;
namespace Legalsoft.Truffer
{
public class Expondist
{
private double bet { get; set; }
public Expondist(double bbet)
{
this.bet = bbet;
if (bet <= 0.0)
{
throw new Exception("bad bet in Expondist");
}
}
public double p(double x)
{
if (x < 0.0)
{
throw new Exception("bad x in Expondist");
}
return bet * Math.Exp(-bet * x);
}
public double cdf(double x)
{
if (x < 0.0)
{
throw new Exception("bad x in Expondist");
}
return 1.0 - Math.Exp(-bet * x);
}
public double invcdf(double p)
{
if (p < 0.0 || p >= 1.0)
{
throw new Exception("bad p in Expondist");
}
return -Math.Log(1.0 - p) / bet;
}
}
}