Update man function

This commit is contained in:
Isaac Shoebottom 2024-02-17 19:50:41 -04:00
parent 9a5f57d20c
commit 3816763622
2 changed files with 50 additions and 35 deletions

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,31 +257,35 @@ def pd_from(x, l):
def man():
print("This module contains functions for computing the total probability of events.")
print("The functions are:")
print("bnd(x, n, p) - The binomial distribution")
print("bnd_mean(n, p) - The mean of the binomial distribution")
print("bnd_var(n, p) - The variance of the binomial distribution")
print("bnd_std(n, p) - The standard deviation of the binomial distribution")
print("bnd_upto(x, n, p) - The cumulative probability of getting upto x successes in n trials")
print("bnd_from(x, n, p) - The cumulative probability of getting from x successes in n trials")
print("gd(x, p, q) - 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_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("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")
"""
Prints the manual for the module.
"""
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")
print("pd_std(l) - The standard deviation of the poisson distribution")
print("pd_upto(x, l) - The cumulative probability of getting upto x occurrences")
print("pd_from(x, l) - The cumulative probability of getting from x occurrences")
"""
This module contains functions for computing the total probability of events.
The functions are:
bnd(x, n, p) - The binomial distribution
bnd_mean(n, p) - The mean of the binomial distribution
bnd_var(n, p) - The variance of the binomial distribution
bnd_std(n, p) - The standard deviation of the binomial distribution
bnd_upto(x, n, p) - The cumulative probability of getting upto x successes in n trials
bnd_from(x, n, p) - The cumulative probability of getting from x successes in n trials
gd(x, p, q) - The geometric distribution
gd_mean(p) - The mean of the geometric distribution
gd_var(p) - The variance of the geometric distribution
gd_std(p) - The standard deviation of the geometric distribution
gd_upto(x, p, q) - The cumulative probability of getting upto x trials until the first success
gd_from(x, p, q) - The cumulative probability of getting from x trials until the first success
hgd(x, N, n, k) - The hyper geometric distribution
hgd_mean(N, n, k) - The mean of the hyper geometric distribution
hgd_var(N, n, k) - The variance of the hyper geometric distribution
hgd_std(N, n, k) - The standard deviation of the hyper geometric distribution
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
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
pd(x, l) - The poisson distribution
pd_mean(l) - The mean of the poisson distribution
pd_var(l) - The variance of the poisson distribution
pd_std(l) - The standard deviation of the poisson distribution
pd_upto(x, l) - The cumulative probability of getting upto x occurrences
pd_from(x, l) - The cumulative probability of getting from x occurrences
""")

View File

@ -34,9 +34,14 @@ def n(A):
def man():
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")
print("u(A, B) - The union of A and B")
print("g(A, B) - The conditional probability of A given B")
print("n(A) - The negation of A")
"""
Prints the manual for the module.
"""
print("""
This module contains functions for computing the total probability of events.
The functions are:
i(A, B) - The intersection of A and B
u(A, B) - The union of A and B
g(A, B) - The conditional probability of A given B
n(A) - The negation of A
""")