Compare commits

...

3 Commits

Author SHA1 Message Date
3426d4575c Fix memory errors 2024-02-17 21:24:22 -04:00
3816763622 Update man function 2024-02-17 19:50:41 -04:00
9a5f57d20c Pycharm shit 2024-02-17 19:33:45 -04:00
3 changed files with 20 additions and 9 deletions

View File

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Calculator.iml" filepath="$PROJECT_DIR$/.idea/Calculator.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/casio-calculator.iml" filepath="$PROJECT_DIR$/.idea/casio-calculator.iml" />
</modules>
</component>
</project>

View File

@ -104,23 +104,29 @@ def gd_std(p):
return gd_var(p) ** 0.5
def gd_upto(x, p):
def gd_upto(x, p, q=None):
"""
Computes the cumulative probability of getting upto x trials until the first success.
:param x: Number of trials until the first success.
:param p: Probability of success.
:param q: Probability of failure.
:return: Returns the cumulative probability of getting upto x trials until the first success.
"""
if q is not None:
return sum(gd(i, p, q) for i in range(1, x + 1))
return sum(gd(i, p) for i in range(1, x + 1))
def gd_from(x, p):
def gd_from(x, p, q=None):
"""
Computes the cumulative probability of getting from x trials until the first success.
:param x: Number of trials until the first success.
:param p: Probability of success.
:param q: Probability of failure.
:return: Returns the cumulative probability of getting from x trials until the first success.
"""
if q is not None:
return 1 - gd_upto(x - 1, p, q)
return 1 - gd_upto(x - 1, p)
@ -251,6 +257,10 @@ def pd_from(x, l):
def man():
"""
Prints the manual for the module.
Formatted this way to fit in memory on the calculator.
"""
print("This module contains functions for computing the total probability of events.")
print("The functions are:")
print("bnd(x, n, p) - The binomial distribution")
@ -263,16 +273,14 @@ def man():
print("gd_mean(p) - The mean of the geometric distribution")
print("gd_var(p) - The variance of the geometric distribution")
print("gd_std(p) - The standard deviation of the geometric distribution")
print("gd_upto(x, p) - The cumulative probability of getting upto x trials until the first success")
print("gd_from(x, p) - The cumulative probability of getting from x trials until the first success")
print("gd_upto(x, p, q) - The cumulative probability of getting upto x trials until the first success")
print("gd_from(x, p, q) - The cumulative probability of getting from x trials until the first success")
print("hgd(x, N, n, k) - The hyper geometric distribution")
print("hgd_mean(N, n, k) - The mean of the hyper geometric distribution")
print("hgd_var(N, n, k) - The variance of the hyper geometric distribution")
print("hgd_std(N, n, k) - The standard deviation of the hyper geometric distribution")
print(
"hgd_upto(x, N, n, k) - The cumulative probability of getting upto x successes in n draws from a population of size N with k successes")
print(
"hgd_from(x, N, n, k) - The cumulative probability of getting from x successes in n draws from a population of size N with k successes")
print("hgd_upto(x, N, n, k) - The cumulative probability of getting upto x successes in n draws from a population of size N with k successes")
print("hgd_from(x, N, n, k) - The cumulative probability of getting from x successes in n draws from a population of size N with k successes")
print("pd(x, l) - The poisson distribution")
print("pd_mean(l) - The mean of the poisson distribution")
print("pd_var(l) - The variance of the poisson distribution")

View File

@ -34,6 +34,9 @@ def n(A):
def man():
"""
Prints the manual for the module.
"""
print("This module contains functions for computing the total probability of events.")
print("The functions are:")
print("i(A, B) - The intersection of A and B")