Aggiunta una quasi totale analisi dei dati dinamici della molla 1. Ore di lavoro meritano il salvataggio.
This commit is contained in:
99
molla/compatibilita/comp1.ipynb
Normal file
99
molla/compatibilita/comp1.ipynb
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "ba4e56bc",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Valori dinamici\n",
|
||||||
|
"N = 10\n",
|
||||||
|
"\n",
|
||||||
|
"A = 23.96 +- 0.16 "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "aaf30c1f",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Valori statici\n",
|
||||||
|
"N = 6\n",
|
||||||
|
"\n",
|
||||||
|
"A = 23.46 +- 0.23\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "b349ba73",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np\n",
|
||||||
|
"from scipy.stats import t as student_t"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"id": "a68eb302",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"t = 1.717\n",
|
||||||
|
"p-value (two-tailed) = 10.8084 %\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# Valori dimanici (sonar)\n",
|
||||||
|
"Nd = 10\n",
|
||||||
|
"Ad = 23.96\n",
|
||||||
|
"uAd = 0.16 * 3\n",
|
||||||
|
"\n",
|
||||||
|
"#Valori statici (calibro)\n",
|
||||||
|
"Ns = 6\n",
|
||||||
|
"As = 23.46\n",
|
||||||
|
"uAs = 0.23 * 3\n",
|
||||||
|
"\n",
|
||||||
|
"#Nomi coerenti con Cannelli\n",
|
||||||
|
"GdL = Nd + Ns - 2\n",
|
||||||
|
"\n",
|
||||||
|
"s2 = ( (Nd - 1) * uAd**2 + (Ns - 1) * uAs**2 ) / GdL\n",
|
||||||
|
"\n",
|
||||||
|
"sigma2 = ( s2 / Nd ) + ( s2 / Ns )\n",
|
||||||
|
"\n",
|
||||||
|
"t = ( Ad - As ) / np.sqrt( sigma2 )\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"p_value = 2 * (1 - student_t.cdf(abs(t), df=GdL))\n",
|
||||||
|
"print(f\"t = {t:.3f}\")\n",
|
||||||
|
"print(f\"p-value (two-tailed) = {p_value * 100:.4f} %\")\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": ".venv",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.13.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
99
molla/compatibilita/comp2.ipynb
Normal file
99
molla/compatibilita/comp2.ipynb
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "ba4e56bc",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Valori dinamici\n",
|
||||||
|
"N = 10\n",
|
||||||
|
"\n",
|
||||||
|
"A = 3.21951 +- 0.00470 "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "aaf30c1f",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Valori statici\n",
|
||||||
|
"N = 6\n",
|
||||||
|
"\n",
|
||||||
|
"A = 3.2002 +- 0.0092\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"id": "b349ba73",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np\n",
|
||||||
|
"from scipy.stats import t as student_t"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"id": "a68eb302",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"t = 5.774\n",
|
||||||
|
"p-value (two-tailed) = 0.0048 %\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"# Valori dimanici (sonar)\n",
|
||||||
|
"Nd = 10\n",
|
||||||
|
"Ad = 3.220\n",
|
||||||
|
"uAd = 0.005\n",
|
||||||
|
"\n",
|
||||||
|
"#Valori statici (calibro)\n",
|
||||||
|
"Ns = 6\n",
|
||||||
|
"As = 3.200\n",
|
||||||
|
"uAs = 0.009\n",
|
||||||
|
"\n",
|
||||||
|
"#Nomi coerenti con Cannelli\n",
|
||||||
|
"GdL = Nd + Ns - 2\n",
|
||||||
|
"\n",
|
||||||
|
"s2 = ( (Nd - 1) * uAd**2 + (Ns - 1) * uAs**2 ) / GdL\n",
|
||||||
|
"\n",
|
||||||
|
"sigma2 = ( s2 / Nd ) + ( s2 / Ns )\n",
|
||||||
|
"\n",
|
||||||
|
"t = ( Ad - As ) / np.sqrt( sigma2 )\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"p_value = 2 * (1 - student_t.cdf(abs(t), df=GdL))\n",
|
||||||
|
"print(f\"t = {t:.3f}\")\n",
|
||||||
|
"print(f\"p-value (two-tailed) = {p_value * 100:.4f} %\")\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": ".venv",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.13.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
5
molla/dinamica/dinamica1.csv
Normal file
5
molla/dinamica/dinamica1.csv
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
m1,a1,ua1,w1,uw1,c1,uc1,a2,ua2,w2,uw2,c2,uc2
|
||||||
|
108.61,9.21,0.029,14.2459,0.0008,268.151,0.02,10.69,0.04,14.2434,0.0009,268.326,0.026
|
||||||
|
128.636666666667,10.037,0.025,13.1939,0.0007,259.605,0.018,9.744,0.027,13.1913,0.0009,259.745,0.02
|
||||||
|
148.38,9.93,0.03,12.3469,0.0007,251.525,0.021,11.41,0.03,12.3461,0.0006,251.542,0.023
|
||||||
|
168.53,11.34,0.03,11.6345,0.0005,243.211,0.021,11.5,0.03,11.6344,0.0006,243.13,0.021
|
||||||
|
6
molla/dinamica/dinamica2.csv
Normal file
6
molla/dinamica/dinamica2.csv
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
m1,a1,ua1,w1,uw1,c1,uc1,t1,a2,ua2,w2,uw2,c2,uc2,t2,a3,ua3,w3,uw3,c3,uc3,t3,a4,ua4,w4,uw4,c4,uc4,t4
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
108.61,11.542,0.026,5.3278,0.0003,303.5502,0.019,22.49,8.424,0.017,5.3282,0.0003,303.581,0.012,22.27,10.501,0.022,5.3296,0.0003,303.842,0.016,22.55,9.959,0.014,5.32822,0.0002,303.445,0.01,22.15
|
||||||
|
128.64,11.574,0.020,4.92663,0.00023,242.962,0.014,24.33,11.592,0.023,4.92537,0.00029,242.876,0.017,24.38,10.264,0.023,4.9243,0.0003,242.789,0.017,25.09,9.118,0.021,4.9261,0.0003,243.115,0.015,24.26
|
||||||
|
1231
molla/dinamica/mollaDinamica1.ipynb
Normal file
1231
molla/dinamica/mollaDinamica1.ipynb
Normal file
File diff suppressed because one or more lines are too long
1058
molla/dinamica/mollaDinamica2.ipynb
Normal file
1058
molla/dinamica/mollaDinamica2.ipynb
Normal file
File diff suppressed because one or more lines are too long
36
molla/dinamica/ripara.py
Normal file
36
molla/dinamica/ripara.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
def replace_every_second_comma(text, replacement=","):
|
||||||
|
result = []
|
||||||
|
comma_count = 0
|
||||||
|
|
||||||
|
for char in text:
|
||||||
|
if char == ",":
|
||||||
|
comma_count += 1
|
||||||
|
if comma_count % 2 == 0:
|
||||||
|
result.append(replacement)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
result.append(".")
|
||||||
|
continue
|
||||||
|
result.append(char)
|
||||||
|
|
||||||
|
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_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_line4 = "108,61,11,542,0,026,5,3278,0,0003,303,5502,0,019,22,49,8,424,0,017,5,3282,0,0003,303,581,0,012,22,27,10,501,0,022,5,3296,0,0003,303,842,0,016,22,55,9,959,0,014,5,32822,0,0002,303,445,0,01,22,15"
|
||||||
|
csv_line5 = "128,64,11,574,0,020,4,92663,0,00023,242,962,0,014,24,33,11,592,0,023,4,92537,0,00029,242,876,0,017,24,38,10,264,0,023,4,9243,0,0003,242,789,0,017,25,09,9,118,0,021,4,9261,0,0003,243,115,0,015,24,26"
|
||||||
|
|
||||||
|
csv_lines = [csv_line1, csv_line2, csv_line3, csv_line4, csv_line5]
|
||||||
|
|
||||||
|
|
||||||
|
for csv_line in csv_lines:
|
||||||
|
fixed_line = replace_every_second_comma(csv_line)
|
||||||
|
|
||||||
|
print(fixed_line)
|
||||||
|
with open("miofile.txt", "a", encoding="utf-8") as f:
|
||||||
|
f.write(fixed_line)
|
||||||
|
f.write("\n")
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 145,
|
"execution_count": null,
|
||||||
"id": "f34c5b88",
|
"id": "f34c5b88",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 146,
|
"execution_count": null,
|
||||||
"id": "08efb2be",
|
"id": "08efb2be",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -100,39 +100,12 @@
|
|||||||
" return media, sigma\n",
|
" return media, sigma\n",
|
||||||
"\n",
|
"\n",
|
||||||
"df = calcola_Dx_stats(df, err_arbitrario_DX=0.01)\n",
|
"df = calcola_Dx_stats(df, err_arbitrario_DX=0.01)\n",
|
||||||
"df = calcola_m_stats(df, err_arbitrario_m=0.0028867513)\n",
|
"df = calcola_m_stats(df, err_arbitrario_m=0.0028867513)\n"
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"'''\n",
|
|
||||||
"df[\"K\"] = df.m * g / df.Dx\n",
|
|
||||||
"df[\"uK\"] = np.sqrt( (df.m * g / df.Dx**2)**2 * df.uDx**2 + (g/df.Dx)**2 * df.um**2 + (df.m / df.Dx)**2 * ug**2)\n",
|
|
||||||
"\n",
|
|
||||||
"df[\"F\"] = df.m * g\n",
|
|
||||||
"df[\"uF\"] = np.sqrt( df.m**2 * ug**2 + g**2 * df.um**2)\n",
|
|
||||||
"media_K, sigma_K = mediaPesata(df[\"K\"], df[\"uK\"])\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"#chi 2\n",
|
|
||||||
"chi2_val = np.sum((df[\"K\"] - media_K)**2 / df[\"uK\"]**2) # formula corretta\n",
|
|
||||||
"dof = len(df[\"K\"]) - 1 # -1 perché stimi solo la media\n",
|
|
||||||
"chi2_rid = chi2_val / dof\n",
|
|
||||||
"p_value = 1 - sc.stats.chi2.cdf(chi2_val, dof)\n",
|
|
||||||
"\n",
|
|
||||||
"print(\"#\"*60)\n",
|
|
||||||
"print(\"Valori di K\")\n",
|
|
||||||
"print(\"media pesata K:\", media_K)\n",
|
|
||||||
"print(\"sigma K:\", sigma_K)\n",
|
|
||||||
"print(f\"Chi2 : {chi2_val:.4f}\")\n",
|
|
||||||
"print(f\"DOF : {dof}\")\n",
|
|
||||||
"print(f\"Chi2 ridotto : {chi2_rid:.4f} (ideale ~ 1)\")\n",
|
|
||||||
"print(f\"p-value : {p_value:.4f}\")\n",
|
|
||||||
"'''"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 147,
|
"execution_count": null,
|
||||||
"id": "5494409f",
|
"id": "5494409f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -272,7 +245,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 148,
|
"execution_count": null,
|
||||||
"id": "976d5531",
|
"id": "976d5531",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -304,6 +277,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"print(perm)\n",
|
"print(perm)\n",
|
||||||
|
"print(len(perm))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"print(\"#\"* 60)\n",
|
"print(\"#\"* 60)\n",
|
||||||
"print(este)\n",
|
"print(este)\n",
|
||||||
@@ -316,7 +290,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 149,
|
"execution_count": null,
|
||||||
"id": "2ad19283",
|
"id": "2ad19283",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -345,7 +319,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 150,
|
"execution_count": null,
|
||||||
"id": "5f59d6c9",
|
"id": "5f59d6c9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -380,7 +354,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 151,
|
"execution_count": null,
|
||||||
"id": "aefe7756",
|
"id": "aefe7756",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -451,7 +425,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 152,
|
"execution_count": null,
|
||||||
"id": "1d42b009",
|
"id": "1d42b009",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -523,7 +497,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 153,
|
"execution_count": null,
|
||||||
"id": "986ff4a6",
|
"id": "986ff4a6",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -559,7 +533,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 154,
|
"execution_count": null,
|
||||||
"id": "ef0817f4",
|
"id": "ef0817f4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -590,7 +564,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 155,
|
"execution_count": null,
|
||||||
"id": "cebe6742",
|
"id": "cebe6742",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -721,7 +695,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 160,
|
"execution_count": null,
|
||||||
"id": "2d4b7144",
|
"id": "2d4b7144",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -799,7 +773,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 157,
|
"execution_count": null,
|
||||||
"id": "32e9948f",
|
"id": "32e9948f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -836,7 +810,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 158,
|
"execution_count": null,
|
||||||
"id": "e2407a04",
|
"id": "e2407a04",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 29,
|
"execution_count": 1,
|
||||||
"id": "f34c5b88",
|
"id": "f34c5b88",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 30,
|
"execution_count": null,
|
||||||
"id": "08efb2be",
|
"id": "08efb2be",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
"'\\ndf[\"K\"] = df.m * g / df.Dx\\ndf[\"uK\"] = np.sqrt( (df.m * g / df.Dx**2)**2 * df.uDx**2 + (g/df.Dx)**2 * df.um**2 + (df.m / df.Dx)**2 * ug**2)\\n\\ndf[\"F\"] = df.m * g\\ndf[\"uF\"] = np.sqrt( df.m**2 * ug**2 + g**2 * df.um**2)\\nmedia_K, sigma_K = mediaPesata(df[\"K\"], df[\"uK\"])\\n\\n\\n#chi 2\\nchi2_val = np.sum((df[\"K\"] - media_K)**2 / df[\"uK\"]**2) # formula corretta\\ndof = len(df[\"K\"]) - 1 # -1 perché stimi solo la media\\nchi2_rid = chi2_val / dof\\np_value = 1 - sc.stats.chi2.cdf(chi2_val, dof)\\n\\nprint(\"#\"*60)\\nprint(\"Valori di K\")\\nprint(\"media pesata K:\", media_K)\\nprint(\"sigma K:\", sigma_K)\\nprint(f\"Chi2 : {chi2_val:.4f}\")\\nprint(f\"DOF : {dof}\")\\nprint(f\"Chi2 ridotto : {chi2_rid:.4f} (ideale ~ 1)\")\\nprint(f\"p-value : {p_value:.4f}\")\\n'"
|
"'\\ndf[\"K\"] = df.m * g / df.Dx\\ndf[\"uK\"] = np.sqrt( (df.m * g / df.Dx**2)**2 * df.uDx**2 + (g/df.Dx)**2 * df.um**2 + (df.m / df.Dx)**2 * ug**2)\\n\\ndf[\"F\"] = df.m * g\\ndf[\"uF\"] = np.sqrt( df.m**2 * ug**2 + g**2 * df.um**2)\\nmedia_K, sigma_K = mediaPesata(df[\"K\"], df[\"uK\"])\\n\\n\\n#chi 2\\nchi2_val = np.sum((df[\"K\"] - media_K)**2 / df[\"uK\"]**2) # formula corretta\\ndof = len(df[\"K\"]) - 1 # -1 perché stimi solo la media\\nchi2_rid = chi2_val / dof\\np_value = 1 - sc.stats.chi2.cdf(chi2_val, dof)\\n\\nprint(\"#\"*60)\\nprint(\"Valori di K\")\\nprint(\"media pesata K:\", media_K)\\nprint(\"sigma K:\", sigma_K)\\nprint(f\"Chi2 : {chi2_val:.4f}\")\\nprint(f\"DOF : {dof}\")\\nprint(f\"Chi2 ridotto : {chi2_rid:.4f} (ideale ~ 1)\")\\nprint(f\"p-value : {p_value:.4f}\")\\n'"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 30,
|
"execution_count": 2,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -100,39 +100,12 @@
|
|||||||
" return media, sigma\n",
|
" return media, sigma\n",
|
||||||
"\n",
|
"\n",
|
||||||
"df = calcola_Dx_stats(df, err_arbitrario_DX=0.01)\n",
|
"df = calcola_Dx_stats(df, err_arbitrario_DX=0.01)\n",
|
||||||
"df = calcola_m_stats(df, err_arbitrario_m=0.0028867513)\n",
|
"df = calcola_m_stats(df, err_arbitrario_m=0.0028867513)\n"
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"'''\n",
|
|
||||||
"df[\"K\"] = df.m * g / df.Dx\n",
|
|
||||||
"df[\"uK\"] = np.sqrt( (df.m * g / df.Dx**2)**2 * df.uDx**2 + (g/df.Dx)**2 * df.um**2 + (df.m / df.Dx)**2 * ug**2)\n",
|
|
||||||
"\n",
|
|
||||||
"df[\"F\"] = df.m * g\n",
|
|
||||||
"df[\"uF\"] = np.sqrt( df.m**2 * ug**2 + g**2 * df.um**2)\n",
|
|
||||||
"media_K, sigma_K = mediaPesata(df[\"K\"], df[\"uK\"])\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"#chi 2\n",
|
|
||||||
"chi2_val = np.sum((df[\"K\"] - media_K)**2 / df[\"uK\"]**2) # formula corretta\n",
|
|
||||||
"dof = len(df[\"K\"]) - 1 # -1 perché stimi solo la media\n",
|
|
||||||
"chi2_rid = chi2_val / dof\n",
|
|
||||||
"p_value = 1 - sc.stats.chi2.cdf(chi2_val, dof)\n",
|
|
||||||
"\n",
|
|
||||||
"print(\"#\"*60)\n",
|
|
||||||
"print(\"Valori di K\")\n",
|
|
||||||
"print(\"media pesata K:\", media_K)\n",
|
|
||||||
"print(\"sigma K:\", sigma_K)\n",
|
|
||||||
"print(f\"Chi2 : {chi2_val:.4f}\")\n",
|
|
||||||
"print(f\"DOF : {dof}\")\n",
|
|
||||||
"print(f\"Chi2 ridotto : {chi2_rid:.4f} (ideale ~ 1)\")\n",
|
|
||||||
"print(f\"p-value : {p_value:.4f}\")\n",
|
|
||||||
"'''"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 31,
|
"execution_count": 3,
|
||||||
"id": "5494409f",
|
"id": "5494409f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -245,7 +218,7 @@
|
|||||||
"3 0.188750 108.610000 0.002887 "
|
"3 0.188750 108.610000 0.002887 "
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 31,
|
"execution_count": 3,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -256,7 +229,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 32,
|
"execution_count": 15,
|
||||||
"id": "976d5531",
|
"id": "976d5531",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -265,6 +238,7 @@
|
|||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n",
|
"[(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\n",
|
||||||
|
"6\n",
|
||||||
"############################################################\n",
|
"############################################################\n",
|
||||||
"[ 61.75666667 121.72666667 181.94666667 59.97 120.19\n",
|
"[ 61.75666667 121.72666667 181.94666667 59.97 120.19\n",
|
||||||
" 60.22 ]\n",
|
" 60.22 ]\n",
|
||||||
@@ -287,6 +261,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"print(perm)\n",
|
"print(perm)\n",
|
||||||
|
"print(len(perm))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"print(\"#\"* 60)\n",
|
"print(\"#\"* 60)\n",
|
||||||
"print(este)\n",
|
"print(este)\n",
|
||||||
@@ -299,7 +274,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 33,
|
"execution_count": 5,
|
||||||
"id": "2ad19283",
|
"id": "2ad19283",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -326,7 +301,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 34,
|
"execution_count": 6,
|
||||||
"id": "5f59d6c9",
|
"id": "5f59d6c9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -361,7 +336,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 35,
|
"execution_count": 7,
|
||||||
"id": "aefe7756",
|
"id": "aefe7756",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -374,8 +349,8 @@
|
|||||||
"Dep. Variable: F R-squared: 1.000\n",
|
"Dep. Variable: F 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: Wed, 01 Apr 2026 Prob (F-statistic): 3.68e-10\n",
|
"Date: Thu, 02 Apr 2026 Prob (F-statistic): 3.68e-10\n",
|
||||||
"Time: 11:24:04 Log-Likelihood: -7.2416\n",
|
"Time: 14:04:37 Log-Likelihood: -7.2416\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",
|
||||||
@@ -440,7 +415,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 36,
|
"execution_count": 8,
|
||||||
"id": "1d42b009",
|
"id": "1d42b009",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -512,7 +487,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 37,
|
"execution_count": 9,
|
||||||
"id": "986ff4a6",
|
"id": "986ff4a6",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -548,7 +523,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 38,
|
"execution_count": 10,
|
||||||
"id": "ef0817f4",
|
"id": "ef0817f4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -564,7 +539,7 @@
|
|||||||
"dtype: float64"
|
"dtype: float64"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 38,
|
"execution_count": 10,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -575,7 +550,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 39,
|
"execution_count": 11,
|
||||||
"id": "cebe6742",
|
"id": "cebe6742",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -663,7 +638,7 @@
|
|||||||
"5 60.220000 0.210270 192.622527 0.044592"
|
"5 60.220000 0.210270 192.622527 0.044592"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 39,
|
"execution_count": 11,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -674,7 +649,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 40,
|
"execution_count": 12,
|
||||||
"id": "2d4b7144",
|
"id": "2d4b7144",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -752,7 +727,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 41,
|
"execution_count": 13,
|
||||||
"id": "32e9948f",
|
"id": "32e9948f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -789,7 +764,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 42,
|
"execution_count": 14,
|
||||||
"id": "e2407a04",
|
"id": "e2407a04",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
Reference in New Issue
Block a user