Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower and Upper Bounds for Cumulative Probability Functions #1

Open
stanislaw-marc opened this issue Mar 13, 2023 · 1 comment
Open
Assignees

Comments

@stanislaw-marc
Copy link
Contributor

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.

@stanislaw-marc stanislaw-marc added the enhancement New feature or request label Mar 13, 2023
@Cillian2113
Copy link
Contributor

Great job buddy

@Cillian2113 Cillian2113 pinned this issue Mar 14, 2023
@berkay-yalin berkay-yalin unpinned this issue Mar 14, 2023
@berkay-yalin berkay-yalin removed the enhancement New feature or request label Jan 16, 2024
berkay-yalin pushed a commit that referenced this issue Jan 16, 2024
Implementing Lower and Upper Bounds for Cumulative Probability Functions #1

Implemented k_upper, and k_lower in binomial and Poisson distributions.
Added test cases for both changed files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants