Compare commits

..

No commits in common. "3426d4575c3a101dfb7f2c872c5e81f46d3e6d09" and "43efbd1a8a6f553a8b78ec42ce5676e75e4b3615" have entirely different histories.

3 changed files with 9 additions and 20 deletions

View File

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

View File

@ -104,29 +104,23 @@ def gd_std(p):
return gd_var(p) ** 0.5 return gd_var(p) ** 0.5
def gd_upto(x, p, q=None): def gd_upto(x, p):
""" """
Computes the cumulative probability of getting upto x trials until the first success. Computes the cumulative probability of getting upto x trials until the first success.
:param x: Number of trials until the first success. :param x: Number of trials until the first success.
:param p: Probability of 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. :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)) return sum(gd(i, p) for i in range(1, x + 1))
def gd_from(x, p, q=None): def gd_from(x, p):
""" """
Computes the cumulative probability of getting from x trials until the first success. Computes the cumulative probability of getting from x trials until the first success.
:param x: Number of trials until the first success. :param x: Number of trials until the first success.
:param p: Probability of 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. :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) return 1 - gd_upto(x - 1, p)
@ -257,10 +251,6 @@ def pd_from(x, l):
def man(): 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("This module contains functions for computing the total probability of events.")
print("The functions are:") print("The functions are:")
print("bnd(x, n, p) - The binomial distribution") print("bnd(x, n, p) - The binomial distribution")
@ -273,14 +263,16 @@ def man():
print("gd_mean(p) - The mean of the geometric distribution") print("gd_mean(p) - The mean of the geometric distribution")
print("gd_var(p) - The variance 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_std(p) - The standard deviation of the geometric distribution")
print("gd_upto(x, p, q) - The cumulative probability of getting upto x trials until the first success") print("gd_upto(x, p) - 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("gd_from(x, p) - The cumulative probability of getting from x trials until the first success")
print("hgd(x, N, n, k) - The hyper geometric distribution") 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_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_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_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(
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") "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(x, l) - The poisson distribution")
print("pd_mean(l) - The mean of the poisson distribution") print("pd_mean(l) - The mean of the poisson distribution")
print("pd_var(l) - The variance of the poisson distribution") print("pd_var(l) - The variance of the poisson distribution")

View File

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