hedtorresca commited on
Commit
8471404
·
verified ·
1 Parent(s): f94ca28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -18,15 +18,15 @@ def validate_inputs(A, B, C, AB, AC, BC, ABC, U):
18
 
19
  def suggest_intersections(A, B, C, AB, AC, BC, ABC, U):
20
  # Máximos valores permitidos para las intersecciones
21
- max_AB = min(A, B, U - (A + B + C - A - B))
22
- max_AC = min(A, C, U - (A + B + C - A - C))
23
- max_BC = min(B, C, U - (A + B + C - B - C))
24
  max_ABC = min(max_AB, max_AC, max_BC)
25
 
26
  # Mínimos valores permitidos para las intersecciones
27
- min_AB = max(0, A + B - U)
28
- min_AC = max(0, A + C - U)
29
- min_BC = max(0, B + C - U)
30
  min_ABC = max(0, A + B + C - U)
31
 
32
  # Máximos y mínimos valores permitidos para los conjuntos
@@ -56,7 +56,7 @@ def suggest_intersections(A, B, C, AB, AC, BC, ABC, U):
56
  return suggestions
57
 
58
  def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
59
- total = U if U > 0 else (A + B + C)
60
  if total == 0:
61
  return {
62
  "P(A)": 0,
@@ -89,8 +89,17 @@ def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
89
  return formatted_probs
90
 
91
  def plot_venn(A, B, C, AB, AC, BC, ABC, U):
 
 
 
 
 
 
 
 
 
92
  plt.figure(figsize=(8, 8))
93
- venn = venn3(subsets=(A, B, AB, C, AC, BC, ABC), set_labels=('A', 'B', 'C'))
94
  plt.title(f"Diagrama de Venn con U = {U}")
95
 
96
  buf = BytesIO()
 
18
 
19
  def suggest_intersections(A, B, C, AB, AC, BC, ABC, U):
20
  # Máximos valores permitidos para las intersecciones
21
+ max_AB = min(A, B, U - (A + B + C - AB - AC - BC + ABC))
22
+ max_AC = min(A, C, U - (A + B + C - AB - AC - BC + ABC))
23
+ max_BC = min(B, C, U - (A + B + C - AB - AC - BC + ABC))
24
  max_ABC = min(max_AB, max_AC, max_BC)
25
 
26
  # Mínimos valores permitidos para las intersecciones
27
+ min_AB = max(0, A + B - U + C)
28
+ min_AC = max(0, A + C - U + B)
29
+ min_BC = max(0, B + C - U + A)
30
  min_ABC = max(0, A + B + C - U)
31
 
32
  # Máximos y mínimos valores permitidos para los conjuntos
 
56
  return suggestions
57
 
58
  def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
59
+ total = U if U > 0 else (A + B + C - AB - AC - BC + ABC)
60
  if total == 0:
61
  return {
62
  "P(A)": 0,
 
89
  return formatted_probs
90
 
91
  def plot_venn(A, B, C, AB, AC, BC, ABC, U):
92
+ subsets = {
93
+ '100': A - AB - AC + ABC,
94
+ '010': B - AB - BC + ABC,
95
+ '001': C - AC - BC + ABC,
96
+ '110': AB - ABC,
97
+ '101': AC - ABC,
98
+ '011': BC - ABC,
99
+ '111': ABC
100
+ }
101
  plt.figure(figsize=(8, 8))
102
+ venn = venn3(subsets=subsets, set_labels=('A', 'B', 'C'))
103
  plt.title(f"Diagrama de Venn con U = {U}")
104
 
105
  buf = BytesIO()