2024-02-17 19:18:01 -04:00
|
|
|
def i(A, B):
|
|
|
|
"""
|
|
|
|
:param A: First probability
|
|
|
|
:param B: Second probability
|
|
|
|
:return: The intersection of A and B
|
|
|
|
"""
|
|
|
|
return A * B
|
|
|
|
|
|
|
|
|
|
|
|
def u(A, B):
|
|
|
|
"""
|
|
|
|
:param A: The first probability
|
|
|
|
:param B: The second probability
|
|
|
|
:return: The union of A and B
|
|
|
|
"""
|
|
|
|
return A + B - i(A, B)
|
|
|
|
|
|
|
|
|
|
|
|
def g(A, B):
|
|
|
|
"""
|
|
|
|
:param A: The first probability
|
|
|
|
:param B: The second probability
|
|
|
|
:return: The conditional probability of A given B
|
|
|
|
"""
|
|
|
|
return g(A, B) / B
|
|
|
|
|
|
|
|
|
|
|
|
def n(A):
|
|
|
|
"""
|
|
|
|
:param A: The probability
|
|
|
|
:return: The negation of A
|
|
|
|
"""
|
|
|
|
return 1 - A
|
|
|
|
|
2024-02-17 19:33:16 -04:00
|
|
|
|
|
|
|
def man():
|
2024-02-17 19:50:41 -04:00
|
|
|
"""
|
|
|
|
Prints the manual for the module.
|
|
|
|
"""
|
2024-02-17 21:24:22 -04:00
|
|
|
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")
|