analisi ben fatta del caso dinamico

This commit is contained in:
2026-04-05 22:04:06 +02:00
parent a0c29b1ae4
commit 84e88fd6e6
6 changed files with 6001 additions and 1241 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -16,7 +16,6 @@ def replace_every_second_comma(text, replacement=","):
return "".join(result) return "".join(result)
# Esempio d'uso
csv_line1 = "49,25,9,7171,0,016,7,6565,0,0004,484,455,0,011,15,62,8,911,0,015,7,6569,0,0004,484,516,0,011,15,58,10,446,0,027,7,6603,0,0005,485,082,0,019,15,76,8,377,0,016,7,6582,0,0004,484,752,0,011,15,87" csv_line1 = "49,25,9,7171,0,016,7,6565,0,0004,484,455,0,011,15,62,8,911,0,015,7,6569,0,0004,484,516,0,011,15,58,10,446,0,027,7,6603,0,0005,485,082,0,019,15,76,8,377,0,016,7,6582,0,0004,484,752,0,011,15,87"
csv_line2 = "69,28,9,860,0,016,6,55968,0,00029,423,352,0,011,18,31,10,390,0,012,6,55891,0,00022,423,154,0,009,18,27,10,491,0,013,6,56002,0,00024,423,697,0,01,18,34,10,968,0,019,6,56,0,0003,423,465,0,014,18,16" csv_line2 = "69,28,9,860,0,016,6,55968,0,00029,423,352,0,011,18,31,10,390,0,012,6,55891,0,00022,423,154,0,009,18,27,10,491,0,013,6,56002,0,00024,423,697,0,01,18,34,10,968,0,019,6,56,0,0003,423,465,0,014,18,16"
csv_line3 = "88,97,11,584,0,014,5,84417,0,0002,363,229,0,01,20,27,10,1763,0,017,5,84585,0,00028,363,354,0,012,20,44,12,044,0,018,5,845,0,00026,363,183,0,013,20,54,11,224,0,016,5,84513,0,00025,363,233,0,011,20,49" csv_line3 = "88,97,11,584,0,014,5,84417,0,0002,363,229,0,01,20,27,10,1763,0,017,5,84585,0,00028,363,354,0,012,20,44,12,044,0,018,5,845,0,00026,363,183,0,013,20,54,11,224,0,016,5,84513,0,00025,363,233,0,011,20,49"
@@ -33,4 +32,3 @@ for csv_line in csv_lines:
with open("miofile.txt", "a", encoding="utf-8") as f: with open("miofile.txt", "a", encoding="utf-8") as f:
f.write(fixed_line) f.write(fixed_line)
f.write("\n") f.write("\n")

View File

@@ -18,7 +18,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 58,
"id": "f34c5b88", "id": "f34c5b88",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -51,7 +51,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 59,
"id": "08efb2be", "id": "08efb2be",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -86,7 +86,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 60,
"id": "5494409f", "id": "5494409f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -215,7 +215,7 @@
"4 168.53 0.002887 " "4 168.53 0.002887 "
] ]
}, },
"execution_count": 3, "execution_count": 60,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -226,7 +226,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 61,
"id": "976d5531", "id": "976d5531",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -282,7 +282,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 62,
"id": "2ad19283", "id": "2ad19283",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -311,7 +311,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 63,
"id": "5f59d6c9", "id": "5f59d6c9",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -360,7 +360,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 64,
"id": "7e75ec05", "id": "7e75ec05",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -387,7 +387,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 65,
"id": "aefe7756", "id": "aefe7756",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -400,8 +400,8 @@
"Dep. Variable: y R-squared: 1.000\n", "Dep. Variable: y R-squared: 1.000\n",
"Model: OLS Adj. R-squared: 1.000\n", "Model: OLS Adj. R-squared: 1.000\n",
"Method: Least Squares F-statistic: 2.238e+04\n", "Method: Least Squares F-statistic: 2.238e+04\n",
"Date: Fri, 03 Apr 2026 Prob (F-statistic): 4.46e-15\n", "Date: Sat, 04 Apr 2026 Prob (F-statistic): 4.46e-15\n",
"Time: 15:28:32 Log-Likelihood: -27.238\n", "Time: 19:37:55 Log-Likelihood: -27.238\n",
"No. Observations: 10 AIC: 58.48\n", "No. Observations: 10 AIC: 58.48\n",
"Df Residuals: 8 BIC: 59.08\n", "Df Residuals: 8 BIC: 59.08\n",
"Df Model: 1 \n", "Df Model: 1 \n",
@@ -449,7 +449,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 66,
"id": "1d42b009", "id": "1d42b009",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -515,7 +515,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 67,
"id": "986ff4a6", "id": "986ff4a6",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -577,7 +577,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 68,
"id": "2d4b7144", "id": "2d4b7144",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -586,8 +586,8 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Ax + B : \n", "Ax + B : \n",
"AC = 24.0474 +- 0.1316\n", "AC = 24.0474 ± 0.1316\n",
"BC = -1.5698 +- 2.0811\n", "BC = -1.5698 ± 2.0811\n",
"cov_ABC = -0.246370\n", "cov_ABC = -0.246370\n",
"P(0, chi²)= 0.9979\n" "P(0, chi²)= 0.9979\n"
] ]
@@ -645,15 +645,15 @@
"\n", "\n",
"AC, BC, uAC, uBC, covABC, chiC = reg_lin(data[\"x\"], data[\"y\"], data[\"ux\"], data[\"uy\"])\n", "AC, BC, uAC, uBC, covABC, chiC = reg_lin(data[\"x\"], data[\"y\"], data[\"ux\"], data[\"uy\"])\n",
"print(\"Ax + B : \")\n", "print(\"Ax + B : \")\n",
"print(f\"AC = {AC:.4f} +- {uAC:.4f}\")\n", "print(f\"AC = {AC:.4f} ± {uAC:.4f}\")\n",
"print(f\"BC = {BC:.4f} +- {uBC:.4f}\")\n", "print(f\"BC = {BC:.4f} ± {uBC:.4f}\")\n",
"print(f\"cov_ABC = {covABC:.6f}\")\n", "print(f\"cov_ABC = {covABC:.6f}\")\n",
"print(f\"P(0, chi²)= {chiC:.4f}\")\n" "print(f\"P(0, chi²)= {chiC:.4f}\")\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 69,
"id": "e2407a04", "id": "e2407a04",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -722,7 +722,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 70,
"id": "32e9948f", "id": "32e9948f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -785,7 +785,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 71,
"id": "bfb895c6", "id": "bfb895c6",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -868,7 +868,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 72,
"id": "202de438", "id": "202de438",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -942,7 +942,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 73,
"id": "caf23dbe", "id": "caf23dbe",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -950,6 +950,8 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"RISULTATI senza ERRORE STRUMENTALE INCLUSO:\n",
"Media pesata K = 23.95113 ± 0.05732\n",
"\n", "\n",
"RISULTATI REGRESSIONE OLS:\n", "RISULTATI REGRESSIONE OLS:\n",
"Aols = 23.96871 ± 0.16022\n", "Aols = 23.96871 ± 0.16022\n",
@@ -969,9 +971,10 @@
} }
], ],
"source": [ "source": [
"print(\"\")\n", "print(\"RISULTATI senza ERRORE STRUMENTALE INCLUSO:\")\n",
"print(f\"Media pesata K = {media:.5f} ± {uA:.5f}\")\n",
"\n", "\n",
"print(\"RISULTATI REGRESSIONE OLS:\")\n", "print(\"\\nRISULTATI REGRESSIONE OLS:\")\n",
"print(f\"Aols = {Aols:.5f} ± {uAols:.5f}\")\n", "print(f\"Aols = {Aols:.5f} ± {uAols:.5f}\")\n",
"print(f\"Bols = {Bols:.5f} ± {uBols:.5f}\")\n", "print(f\"Bols = {Bols:.5f} ± {uBols:.5f}\")\n",
"print(f\"P(0, chi²)= {Pols:.5f}\")\n", "print(f\"P(0, chi²)= {Pols:.5f}\")\n",
@@ -997,7 +1000,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 74,
"id": "8f5c8bb7", "id": "8f5c8bb7",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -1046,7 +1049,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 75,
"id": "a1dc24c9", "id": "a1dc24c9",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -1098,7 +1101,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 76,
"id": "c8e264fa", "id": "c8e264fa",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [

View File

@@ -5,7 +5,7 @@
"id": "3a8dfc0e", "id": "3a8dfc0e",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Analisi della molla statica 2" "# Analisi della molla statica con calibro 2"
] ]
}, },
{ {
@@ -18,7 +18,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 141, "execution_count": 82,
"id": "f34c5b88", "id": "f34c5b88",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -51,7 +51,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 142, "execution_count": 83,
"id": "08efb2be", "id": "08efb2be",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -86,7 +86,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 143, "execution_count": 84,
"id": "5494409f", "id": "5494409f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -199,7 +199,7 @@
"3 0.188750 108.610000 0.002887 " "3 0.188750 108.610000 0.002887 "
] ]
}, },
"execution_count": 143, "execution_count": 84,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@@ -210,7 +210,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 144, "execution_count": 85,
"id": "976d5531", "id": "976d5531",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -265,7 +265,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 145, "execution_count": 86,
"id": "2ad19283", "id": "2ad19283",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -292,7 +292,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 146, "execution_count": 87,
"id": "5f59d6c9", "id": "5f59d6c9",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -341,7 +341,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 147, "execution_count": 88,
"id": "7e75ec05", "id": "7e75ec05",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -368,7 +368,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 148, "execution_count": 89,
"id": "aefe7756", "id": "aefe7756",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -381,8 +381,8 @@
"Dep. Variable: y R-squared: 1.000\n", "Dep. Variable: y R-squared: 1.000\n",
"Model: OLS Adj. R-squared: 1.000\n", "Model: OLS Adj. R-squared: 1.000\n",
"Method: Least Squares F-statistic: 1.277e+05\n", "Method: Least Squares F-statistic: 1.277e+05\n",
"Date: Fri, 03 Apr 2026 Prob (F-statistic): 3.68e-10\n", "Date: Sat, 04 Apr 2026 Prob (F-statistic): 3.68e-10\n",
"Time: 15:05:08 Log-Likelihood: -7.2422\n", "Time: 19:38:07 Log-Likelihood: -7.2422\n",
"No. Observations: 6 AIC: 18.48\n", "No. Observations: 6 AIC: 18.48\n",
"Df Residuals: 4 BIC: 18.07\n", "Df Residuals: 4 BIC: 18.07\n",
"Df Model: 1 \n", "Df Model: 1 \n",
@@ -438,7 +438,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 149, "execution_count": 90,
"id": "1d42b009", "id": "1d42b009",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -504,7 +504,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 150, "execution_count": 91,
"id": "986ff4a6", "id": "986ff4a6",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -562,7 +562,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 151, "execution_count": 92,
"id": "2d4b7144", "id": "2d4b7144",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -571,8 +571,8 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Ax + B : \n", "Ax + B : \n",
"AC = 3.2005 +- 0.0092\n", "AC = 3.2005 ± 0.0092\n",
"BC = 0.1195 +- 0.9524\n", "BC = 0.1195 ± 0.9524\n",
"cov_ABC = -0.007942\n", "cov_ABC = -0.007942\n",
"P(0, chi²)= 0.4020\n" "P(0, chi²)= 0.4020\n"
] ]
@@ -630,15 +630,15 @@
"\n", "\n",
"AC, BC, uAC, uBC, covABC, chiC = reg_lin(data[\"x\"], data[\"y\"], data[\"ux\"], data[\"uy\"])\n", "AC, BC, uAC, uBC, covABC, chiC = reg_lin(data[\"x\"], data[\"y\"], data[\"ux\"], data[\"uy\"])\n",
"print(\"Ax + B : \")\n", "print(\"Ax + B : \")\n",
"print(f\"AC = {AC:.4f} +- {uAC:.4f}\")\n", "print(f\"AC = {AC:.4f} ± {uAC:.4f}\")\n",
"print(f\"BC = {BC:.4f} +- {uBC:.4f}\")\n", "print(f\"BC = {BC:.4f} ± {uBC:.4f}\")\n",
"print(f\"cov_ABC = {covABC:.6f}\")\n", "print(f\"cov_ABC = {covABC:.6f}\")\n",
"print(f\"P(0, chi²)= {chiC:.4f}\")\n" "print(f\"P(0, chi²)= {chiC:.4f}\")\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 152, "execution_count": 93,
"id": "e2407a04", "id": "e2407a04",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -707,7 +707,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 153, "execution_count": 94,
"id": "32e9948f", "id": "32e9948f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -766,7 +766,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 154, "execution_count": 95,
"id": "bfb895c6", "id": "bfb895c6",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -849,7 +849,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 155, "execution_count": 96,
"id": "202de438", "id": "202de438",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -923,7 +923,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 160, "execution_count": 97,
"id": "caf23dbe", "id": "caf23dbe",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -931,6 +931,8 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"RISULTATI senza ERRORE STRUMENTALE INCLUSO:\n",
"Media pesata K = 3.20156 ± 0.00386\n",
"\n", "\n",
"RISULTATI REGRESSIONE OLS:\n", "RISULTATI REGRESSIONE OLS:\n",
"Aols = 3.20145 ± 0.00896\n", "Aols = 3.20145 ± 0.00896\n",
@@ -950,9 +952,10 @@
} }
], ],
"source": [ "source": [
"print(\"\")\n", "print(\"RISULTATI senza ERRORE STRUMENTALE INCLUSO:\")\n",
"print(f\"Media pesata K = {media:.5f} ± {uA:.5f}\")\n",
"\n", "\n",
"print(\"RISULTATI REGRESSIONE OLS:\")\n", "print(\"\\nRISULTATI REGRESSIONE OLS:\")\n",
"print(f\"Aols = {Aols:.5f} ± {uAols:.5f}\")\n", "print(f\"Aols = {Aols:.5f} ± {uAols:.5f}\")\n",
"print(f\"Bols = {Bols:.5f} ± {uBols:.5f}\")\n", "print(f\"Bols = {Bols:.5f} ± {uBols:.5f}\")\n",
"print(f\"P(0, chi²)= {Pols:.5f}\")\n", "print(f\"P(0, chi²)= {Pols:.5f}\")\n",
@@ -978,7 +981,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 157, "execution_count": 98,
"id": "8f5c8bb7", "id": "8f5c8bb7",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -1027,7 +1030,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 158, "execution_count": 99,
"id": "a1dc24c9", "id": "a1dc24c9",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -1074,12 +1077,12 @@
"id": "2e57c7d8", "id": "2e57c7d8",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Risutltati della propagazione dell'errore strumentale massimo" "## Risultati della propagazione dell'errore strumentale massimo"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 164, "execution_count": 100,
"id": "c8e264fa", "id": "c8e264fa",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [