Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -84,13 +84,33 @@ y = p/n
|
|
84 |
st.sidebar.text(f"Value for y = p/n: {y:.4f}")
|
85 |
|
86 |
# Add fineness control
|
|
|
87 |
fineness = st.sidebar.slider(
|
88 |
-
"
|
89 |
min_value=20,
|
90 |
max_value=500,
|
91 |
value=100,
|
92 |
step=10,
|
93 |
-
help="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
)
|
95 |
|
96 |
# Generate button
|
@@ -108,7 +128,17 @@ if st.sidebar.button("Generate Plot", type="primary"):
|
|
108 |
os.remove(data_file)
|
109 |
|
110 |
# Execute the C++ program
|
111 |
-
cmd = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
process = subprocess.Popen(
|
114 |
cmd,
|
@@ -186,8 +216,8 @@ if st.sidebar.button("Generate Plot", type="primary"):
|
|
186 |
ax.legend(loc='best', fontsize=12, framealpha=0.9)
|
187 |
|
188 |
# Add formulas as text
|
189 |
-
formula_text1 = r"Max Function: $\max_{k \in (0,\infty)} \frac{y\beta(a-1)k + (ak+1)((y-1)k-1)}{(ak+1)(k^2+k)
|
190 |
-
formula_text2 = r"Min Function: $\min_{t \in (-1/a,0)} \frac{y\beta(a-1)t + (at+1)((y-1)t-1)}{(at+1)(t^2+t)
|
191 |
|
192 |
plt.figtext(0.02, 0.02, formula_text1, fontsize=10, color='green')
|
193 |
plt.figtext(0.55, 0.02, formula_text2, fontsize=10, color='purple')
|
@@ -233,6 +263,12 @@ if st.sidebar.button("Generate Plot", type="primary"):
|
|
233 |
st.write(f"Empirical Min: {min(min_eigenvalues):.6f}")
|
234 |
st.write(f"Theoretical Min: {min(theoretical_min):.6f}")
|
235 |
st.write(f"Difference: {abs(min(min_eigenvalues) - min(theoretical_min)):.6f}")
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
except Exception as e:
|
238 |
st.error(f"An error occurred: {str(e)}")
|
@@ -265,13 +301,18 @@ with st.expander("About Eigenvalue Analysis"):
|
|
265 |
- **p**: Dimension
|
266 |
- **a**: Value > 1 that affects the distribution of eigenvalues
|
267 |
- **y**: Value calculated as p/n that affects scaling
|
268 |
-
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
### Mathematical Formulas
|
271 |
|
272 |
Max Function:
|
273 |
-
max{k ∈ (0,∞)} [yβ(a-1)k + (ak+1)((y-1)k-1)]/[(ak+1)(k²+k)
|
274 |
|
275 |
Min Function:
|
276 |
-
min{t ∈ (-1/a,0)} [yβ(a-1)t + (at+1)((y-1)t-1)]/[(at+1)(t²+t)
|
277 |
""")
|
|
|
84 |
st.sidebar.text(f"Value for y = p/n: {y:.4f}")
|
85 |
|
86 |
# Add fineness control
|
87 |
+
st.sidebar.subheader("Calculation Controls")
|
88 |
fineness = st.sidebar.slider(
|
89 |
+
"Beta points",
|
90 |
min_value=20,
|
91 |
max_value=500,
|
92 |
value=100,
|
93 |
step=10,
|
94 |
+
help="Number of points to calculate along the β axis (0 to 1)"
|
95 |
+
)
|
96 |
+
|
97 |
+
# Add controls for theoretical calculation precision
|
98 |
+
theory_grid_points = st.sidebar.slider(
|
99 |
+
"Theoretical grid points",
|
100 |
+
min_value=100,
|
101 |
+
max_value=1000,
|
102 |
+
value=200,
|
103 |
+
step=50,
|
104 |
+
help="Number of points in initial grid search for theoretical calculations"
|
105 |
+
)
|
106 |
+
|
107 |
+
theory_tolerance = st.sidebar.number_input(
|
108 |
+
"Theoretical tolerance",
|
109 |
+
min_value=1e-12,
|
110 |
+
max_value=1e-6,
|
111 |
+
value=1e-10,
|
112 |
+
format="%.1e",
|
113 |
+
help="Convergence tolerance for golden section search"
|
114 |
)
|
115 |
|
116 |
# Generate button
|
|
|
128 |
os.remove(data_file)
|
129 |
|
130 |
# Execute the C++ program
|
131 |
+
cmd = [
|
132 |
+
executable,
|
133 |
+
str(n),
|
134 |
+
str(p),
|
135 |
+
str(a),
|
136 |
+
str(y),
|
137 |
+
str(fineness),
|
138 |
+
str(theory_grid_points),
|
139 |
+
str(theory_tolerance),
|
140 |
+
data_file
|
141 |
+
]
|
142 |
|
143 |
process = subprocess.Popen(
|
144 |
cmd,
|
|
|
216 |
ax.legend(loc='best', fontsize=12, framealpha=0.9)
|
217 |
|
218 |
# Add formulas as text
|
219 |
+
formula_text1 = r"Max Function: $\max_{k \in (0,\infty)} \frac{y\beta(a-1)k + (ak+1)((y-1)k-1)}{(ak+1)(k^2+k)}$"
|
220 |
+
formula_text2 = r"Min Function: $\min_{t \in (-1/a,0)} \frac{y\beta(a-1)t + (at+1)((y-1)t-1)}{(at+1)(t^2+t)}$"
|
221 |
|
222 |
plt.figtext(0.02, 0.02, formula_text1, fontsize=10, color='green')
|
223 |
plt.figtext(0.55, 0.02, formula_text2, fontsize=10, color='purple')
|
|
|
263 |
st.write(f"Empirical Min: {min(min_eigenvalues):.6f}")
|
264 |
st.write(f"Theoretical Min: {min(theoretical_min):.6f}")
|
265 |
st.write(f"Difference: {abs(min(min_eigenvalues) - min(theoretical_min)):.6f}")
|
266 |
+
|
267 |
+
# Display calculation settings
|
268 |
+
with st.expander("Calculation Settings"):
|
269 |
+
st.write(f"Beta points: {fineness}")
|
270 |
+
st.write(f"Theoretical grid points: {theory_grid_points}")
|
271 |
+
st.write(f"Theoretical tolerance: {theory_tolerance:.1e}")
|
272 |
|
273 |
except Exception as e:
|
274 |
st.error(f"An error occurred: {str(e)}")
|
|
|
301 |
- **p**: Dimension
|
302 |
- **a**: Value > 1 that affects the distribution of eigenvalues
|
303 |
- **y**: Value calculated as p/n that affects scaling
|
304 |
+
|
305 |
+
### Calculation Controls
|
306 |
+
|
307 |
+
- **Beta points**: Number of points calculated along the β range (0 to 1)
|
308 |
+
- **Theoretical grid points**: Number of points in initial grid search for finding theoretical max/min
|
309 |
+
- **Theoretical tolerance**: Convergence tolerance for golden section search algorithm
|
310 |
|
311 |
### Mathematical Formulas
|
312 |
|
313 |
Max Function:
|
314 |
+
max{k ∈ (0,∞)} [yβ(a-1)k + (ak+1)((y-1)k-1)]/[(ak+1)(k²+k)]
|
315 |
|
316 |
Min Function:
|
317 |
+
min{t ∈ (-1/a,0)} [yβ(a-1)t + (at+1)((y-1)t-1)]/[(at+1)(t²+t)]
|
318 |
""")
|