Git Product home page Git Product logo

promethium's People

Contributors

berkay-yalin avatar cillian2113 avatar sbhat92 avatar stanislaw-marc avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

promethium's Issues

Replace "validate" functions with nan for distributions

Instead of raising exceptions within the "validate" functions when invalid arguments are used with the distribution functions, the nan value should be returned.

The reasoning behind this decision is to support large scale operations on arrays.

This makes identifying invalid arguments much more difficult, as the current "validate" functions provide detailed descriptions for why the arguments are rejected, so a more effective solution is welcome for discussion.

Example "validate" function, where each distribution function has its separate "validate" function:

def pmf_validate(x: Any, n: Any, p: Any) -> None:
if not isinstance(x, int):
raise TypeError("x must be a non-negative integer")
if x < 0:
raise ValueError("x value out of domain")
if not isinstance(n, int):
raise TypeError("n must be a non-negative integer")
if n < 0:
raise ValueError("n value out of domain")
if not isinstance(p, float):
raise TypeError("p must be non-negative float")
if not 0 <= p <= 1:
raise ValueError("p value out of domain")

Lower and Upper Bounds for Cumulative Probability Functions

Currently, the cumulative probability functions only have the upper bound as a parameter (k in both cases), and use 0 for the lower bound.

https://github.com/berkay-yalin/python-probabilities/blob/c9c9e55a444bec83d71221a26fa5fe181d8c669f/python_probabilities/distributions_binomial.py#L21-L22

https://github.com/berkay-yalin/python-probabilities/blob/c9c9e55a444bec83d71221a26fa5fe181d8c669f/python_probabilities/distributions_poisson.py#L21-L22

This approach works well when calculating probabilities below a certain number (e.g., P(X≤7)), but becomes more complicated when trying to calculate a range of values (e.g., P(4≤X≤7)).

In this case, to calculate it using the currently available functions we would have to calculate the following P(X≤7) - P(X≤3).
For example, if we were using a binomial distribution of X ~ B(11, 0.33), we would calculate P(4≤X≤7) like this:

from python_probabilities import *
print(Bcd(7,11,0.33) - Bcd(3,11,0.33))

Which gives us an output of 0.5096391069522413707200.

Therefore, I suggest adding an optional lower parameter to the cumulative probability functions, which would default to 0 if not passed into the function. This would make it easier to calculate the probability of a range of values without the need to subtract two probabilities. Additionally, this would increase the efficiency of the algorithm, as it would avoid the need for the functions to iterate twice through the same probabilities.

Inconsistent return types & parameter naming

Inconsistent return types

Some of the distribution functions return a float whilst others return a decimal.Decimal.
All distribution functions should be consistent in their return types.

Inconsistent parameter naming

Inconsistent naming for parameters of various functions where the actual parameters represent the same thing.
For example, InvBinomialCD uses y whereas InvGeometricCD uses area:

https://github.com/berkay-yalin/python-probabilities/blob/d8585c2c41af3152a365e387ccb5b974b265aeca/python_probabilities/distributions_binomial.py#L59-L61

https://github.com/berkay-yalin/python-probabilities/blob/d8585c2c41af3152a365e387ccb5b974b265aeca/python_probabilities/distributions_geometric.py#L30-L35

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.