Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,6 +26,9 @@ def validate_inputs(A, B, C, AB, AC, BC, ABC, U):
|
|
26 |
|
27 |
return errors
|
28 |
|
|
|
|
|
|
|
29 |
def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
|
30 |
# Probabilidades individuales
|
31 |
P_A = A / U
|
@@ -45,13 +48,13 @@ def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
|
|
45 |
P_B_total = P_A * P_B_given_A + P_C * P_B_given_C - P_A_given_C * P_C_given_A * P_B_given_A * P_B_given_C
|
46 |
P_C_total = P_A * P_C_given_A + P_B * P_C_given_B - P_A_given_B * P_B_given_A * P_C_given_A * P_C_given_B
|
47 |
|
48 |
-
# Teorema de Bayes (
|
49 |
-
P_A_given_B_bayes = (
|
50 |
-
P_B_given_A_bayes = (
|
51 |
-
P_A_given_C_bayes = (
|
52 |
-
P_C_given_A_bayes = (
|
53 |
-
P_B_given_C_bayes = (
|
54 |
-
P_C_given_B_bayes = (
|
55 |
|
56 |
return {
|
57 |
"P(A)": P_A,
|
|
|
26 |
|
27 |
return errors
|
28 |
|
29 |
+
def bayes_theorem(P_prior, P_likelihood, P_marginal):
|
30 |
+
return (P_likelihood * P_prior) / P_marginal
|
31 |
+
|
32 |
def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
|
33 |
# Probabilidades individuales
|
34 |
P_A = A / U
|
|
|
48 |
P_B_total = P_A * P_B_given_A + P_C * P_B_given_C - P_A_given_C * P_C_given_A * P_B_given_A * P_B_given_C
|
49 |
P_C_total = P_A * P_C_given_A + P_B * P_C_given_B - P_A_given_B * P_B_given_A * P_C_given_A * P_C_given_B
|
50 |
|
51 |
+
# Teorema de Bayes (dinámico)
|
52 |
+
P_A_given_B_bayes = bayes_theorem(P_A, P_B_given_A, P_B)
|
53 |
+
P_B_given_A_bayes = bayes_theorem(P_B, P_A_given_B, P_A)
|
54 |
+
P_A_given_C_bayes = bayes_theorem(P_A, P_C_given_A, P_C)
|
55 |
+
P_C_given_A_bayes = bayes_theorem(P_C, P_A_given_C, P_A)
|
56 |
+
P_B_given_C_bayes = bayes_theorem(P_B, P_C_given_B, P_C)
|
57 |
+
P_C_given_B_bayes = bayes_theorem(P_C, P_B_given_C, P_B)
|
58 |
|
59 |
return {
|
60 |
"P(A)": P_A,
|