Kfong commited on
Commit
1d49930
1 Parent(s): c45318f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -40
app.py CHANGED
@@ -3,50 +3,45 @@ import numpy as np
3
  import matplotlib.pyplot as plt
4
 
5
  def analizar_inversiones(lista1, lista2):
6
- array1 = np.array(lista1)
7
- array2 = np.array(lista2)
8
-
9
- # Calcular desvest
10
- std_dev1 = np.std(array1)
11
- std_dev2 = np.std(array2)
12
-
13
- # Calcular valor esperado
14
- mean1 = np.mean(array1)
15
- mean2 = np.mean(array2)
16
-
17
- # Calcular correlación
18
- correlation = np.corrcoef(array1, array2)[0, 1]
19
-
20
- # Crear gráfica
21
- fig, ax = plt.subplots()
22
- ax.scatter(array1, array2)
23
- ax.set_xlabel('Lista 1')
24
- ax.set_ylabel('Lista 2')
25
- ax.set_title('Investment graph')
26
- ax.grid(True)
27
- st.pyplot(fig)
28
 
29
  # Decidir a cuál invertir más y a cuál menos
30
- if mean1 > mean2:
31
- invertir_mas = "List 1"
32
- invertir_menos = "List 2"
33
- else:
34
- invertir_mas = "List 2"
35
- invertir_menos = "List 1"
36
-
37
- # Mostrar resultados con un formato agradable
38
- st.write("Results of the Analisis:")
39
- st.write(f"Standar desviation of list 1: {std_dev1}")
40
- st.write(f"Standar desviation of list 2: {std_dev2}")
41
- st.write(f"Estimated value list 1: {mean1}")
42
- st.write(f"Estimated value list 2: {mean2}")
43
- st.write(f"Correlation: {correlation}")
44
- st.write(f"Invest more in: {invertir_mas}")
45
- st.write(f"Invest less in: {invertir_menos}")
46
 
47
  def main():
48
- st.title("Variance Portfolio")
49
- st.write("Insert the values for the lists:")
50
 
51
  # Solicitar al usuario que ingrese los valores de las listas
52
  lista1 = [st.number_input(f"List 1 - Value {i+1}", value=0.0) for i in range(10)]
 
3
  import matplotlib.pyplot as plt
4
 
5
  def analizar_inversiones(lista1, lista2):
6
+ array1 = np.array(lista1)
7
+ array2 = np.array(lista2)
8
+
9
+ std_dev1 = np.std(array1)
10
+ std_dev2 = np.std(array2)
11
+
12
+ mean1 = np.mean(array1)
13
+ mean2 = np.mean(array2)
14
+
15
+ correlation = np.corrcoef(array1, array2)[0, 1]
16
+
17
+ fig, ax = plt.subplots()
18
+ ax.scatter(array1, array2)
19
+ ax.set_xlabel('Lista 1')
20
+ ax.set_ylabel('Lista 2')
21
+ ax.set_title('Investment graph')
22
+ ax.grid(True)
23
+ st.pyplot(fig)
 
 
 
 
24
 
25
  # Decidir a cuál invertir más y a cuál menos
26
+ if mean1 > mean2:
27
+ invertir_mas = "List 1"
28
+ invertir_menos = "List 2"
29
+ else:
30
+ invertir_mas = "List 2"
31
+ invertir_menos = "List 1"
32
+
33
+ st.write("Results of the Analisis:")
34
+ st.write(f"Standar desviation of list 1: {std_dev1}")
35
+ st.write(f"Standar desviation of list 2: {std_dev2}")
36
+ st.write(f"Estimated value list 1: {mean1}")
37
+ st.write(f"Estimated value list 2: {mean2}")
38
+ st.write(f"Correlation: {correlation}")
39
+ st.write(f"Invest more in: {invertir_mas}")
40
+ st.write(f"Invest less in: {invertir_menos}")
 
41
 
42
  def main():
43
+ st.title("Variance Portfolio")
44
+ st.write("Insert the values for the lists:")
45
 
46
  # Solicitar al usuario que ingrese los valores de las listas
47
  lista1 = [st.number_input(f"List 1 - Value {i+1}", value=0.0) for i in range(10)]