Skip to content

Add a cdf() and ppf() method to sci.dist #8

@aktau

Description

@aktau

We currently only have pdf (https://scilua.org/sci_dist.html):

y = sd:pdf(x)
Returns the value of the probability density function (for continuous distributions) or of the mass probability function (for discrete distributions) computed at x for sd. The domain of this function is the real line.

But I would like to calculate confidence intervals using the Beta distrbution:

dist = require('sci.dist')
local d = dist.beta(5,17)
print(d:ppf(0.05), d:ppf(0.95))

Example equivalent currently possible with scipy:

>>> from scipy.stats import beta
>>> print(beta.ppf([0.05, 0.95], 5, 17))
[0.09884353 0.38440811]

This seems to be based on the cephes C library. E.g.: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.btdtri.html#scipy.special.btdtri

For this I'd need the latter of:

y = sd:cdf(x): the cumulative distribution function at x (find x for cdf(y) = x)
y = sd:ppf(x): the inverse of the cumulative distribution function at x (find x for cdf(x) = y)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions