Skip to content

MathNet EXCEL extension #437

Open
Open
@toolgood

Description

@toolgood
public static partial class ExcelFunctions
    {
        //public static double ChiDist(double x, double freedom)
        //{
        //    return Chi.PDF(x, freedom);//Is Error
        //}

        public static double ExponDist(double x, double rate, bool state)
        {
            if (state) {
                return Exponential.CDF(rate, x);
            }
            return Exponential.PDF(rate, x);

        }

        public static double HypgeomDist(int k, int draws, int success, int population)
        {
            return Hypergeometric.PMF(population, success, draws, k);
        }


        public static double NegbinomDist(int k, double r, double p)
        {
            return NegativeBinomial.PMF(r, p, k);

        }

        public static double LognormDist(double x, double mu, double sigma)
        {
            return LogNormal.CDF(mu, sigma, x);
        }

        public static double LogInv(double p, double mu, double sigma)
        {
            return LogNormal.InvCDF(mu, sigma, p);
        }

        public static double BinomDist(int k, int n, double p, bool state)
        {
            if (state == false) {
                return Binomial.PMF(p, n, k);
            }
            return Binomial.CDF(p, n, k);
        }

        public static double POISSON(int k, double lambda, bool state)
        {
            if (state == false) {
                return Poisson.PMF(lambda, k);
            }
            return Poisson.CDF(lambda, k);
        }
        public static double WEIBULL(double x, double shape, double scale,  bool state)
        {
            if (state == false) {
                return Weibull.PDF(shape, scale, x);
            }
            return Weibull.CDF(shape, scale, x);
        }


    }

ChiDist failed, I do not know why it went wrong!

In Excel, "= CHIDIST (1,2)" shows 0.60653066
In the code "Chi.PDF (2, 1)" shows 0.60653065971263365

In Excel, "= CHIDIST (1,3)" shows 0.801251957
In the code "Chi.PDF (3, 1)" shows 0.4839414490382859

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions