C#,数值计算——指数分布(Expondist)的计算方法与源程序

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;
        }
    }
}
 

猜你喜欢

转载自blog.csdn.net/beijinghorn/article/details/131745201
今日推荐