8 Commits

9 changed files with 4726 additions and 20 deletions

634
Funzioni/Statistica.ipynb Normal file
View File

@@ -0,0 +1,634 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "e1f82c70",
"metadata": {},
"source": [
"# Import librerie"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "b2b806a7",
"metadata": {},
"outputs": [],
"source": [
"# Heavy lifting\n",
"import numpy as np\n",
"import pandas as pd\n",
"from scipy import stats\n",
"\n",
"# Mostrare i dati\n",
"import ipysheet\n",
"from IPython.display import display\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"\n",
"# Calcolo simbolico\n",
"import sympy as sp"
]
},
{
"cell_type": "markdown",
"id": "96b0e93d",
"metadata": {},
"source": [
"# Compatibilità"
]
},
{
"cell_type": "markdown",
"id": "e50c6d18",
"metadata": {},
"source": [
"**compat( x1, x2, u1, u2 )**\n",
"\n",
"*input:*\n",
" - x1, x2: quantità\n",
" - u1, u2: incertezze associate\n",
"\n",
"*output:*\n",
" - k: fattore di compatibilità (scarto normalizzato)\n",
" - diff: differenza x1 - x2"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "d07a554d",
"metadata": {},
"outputs": [],
"source": [
"def compat(x1, x2, u1,u2):\n",
" \n",
" diff = x1 - x2\n",
" k = np.abs(diff) / np.sqrt(u1**2 + u2**2)\n",
" return k, diff"
]
},
{
"cell_type": "markdown",
"id": "bc3e1539",
"metadata": {},
"source": [
"# Classe Data\n",
"\n",
"*attributi:*\n",
"\n",
"- campione: dati grezzi\n",
"- analisi_stat:\n",
" - valori medi\n",
" - incertezze strumentali, statistiche e complessive\n",
" - lunghezza campione\n",
" - outlier\n",
" - residui con incertezza\n",
"- param_reg:\n",
" - A, B\n",
" - uA, uB, covAB\n",
" - chi², P"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "2649eb4e",
"metadata": {},
"outputs": [],
"source": [
"class Data:\n",
"\n",
" def __init__(self,\n",
" campione,\n",
" analisi_stat=None, param_reg=None):\n",
" \n",
" self.campione = campione\n",
" self.analisi_stat = analisi_stat\n",
" self.param_reg = param_reg"
]
},
{
"cell_type": "markdown",
"id": "a21e942b",
"metadata": {},
"source": [
"## Analisi con criterio di Chauvenet"
]
},
{
"cell_type": "markdown",
"id": "050285f6",
"metadata": {},
"source": [
"**data.stat_chauv( prefissi, err_strumentale )**\n",
"\n",
"*input data.campione:*\n",
" - prefix: nome/lista di nomi delle variabili da analizzare\n",
" - err_strumentale: incertezza/lista di incertezze da risoluzione strumentale\n",
"\n",
"*output data.analisi_stat:* \n",
" - \\<prefix>: media del campione\n",
" - u\\<prefix>_strum: incertezzaa da risoluzione strumentale\n",
" - u\\<prefix>_stat: incertezza statistica (s/sqrt(N))\n",
" - u\\<prefix>: incertezza complessiva\n",
" - n\\<prexix>: lunghezza del campione\n",
" - out\\<prefix>: lista outlier"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "91931bb9",
"metadata": {},
"outputs": [],
"source": [
"# Probabilità\n",
"def p_t_student(valori, err_strumentale):\n",
"\n",
" n = len(valori)\n",
" GdL = n - 1\n",
"\n",
" media = valori.mean()\n",
" s = valori.std(ddof=1)\n",
"\n",
" s = np.sqrt(s**2 + err_strumentale**2)\n",
" return 2 * (1 - stats.t.cdf(np.abs(valori - media) / s, df=GdL))\n",
"\n",
"\n",
"# Indice del peggiore outlier o None\n",
"def trova_outlier(valori, err_strumentale):\n",
"\n",
" n = len(valori)\n",
" soglia = 1 / (2 * n)\n",
" p = p_t_student(valori, err_strumentale)\n",
" idx_min = np.argmin(p)\n",
"\n",
" if p[idx_min] < soglia:\n",
" return idx_min\n",
" \n",
" return None\n",
"\n",
"\n",
"# Rimozione outlier\n",
"def rimuovi_outlier(valori, err_strumentale):\n",
" \n",
" rimossi = []\n",
" campione = valori.copy()\n",
"\n",
" while len(campione) > 2:\n",
" idx = trova_outlier(campione, err_strumentale)\n",
"\n",
" if idx is None: # nessun outlier: stop\n",
" break\n",
"\n",
" rimossi.append(campione[idx])\n",
" campione = np.delete(campione, idx)\n",
"\n",
" return campione, rimossi"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "70c37b24",
"metadata": {},
"outputs": [],
"source": [
"# Analisi statistica con criterio di Chauvenet\n",
"def stat_chauv(self, prefissi, err_strumentale):\n",
"\n",
" analisi_stat = self.analisi_stat\n",
" campione = self.campione\n",
" \n",
" \n",
" if isinstance(prefissi, str):\n",
" prefissi = [prefissi]\n",
" if isinstance(err_strumentale, (int, float)):\n",
" err_strumentale = [err_strumentale] * len(prefissi)\n",
"\n",
" for prefix, err_strum in zip(prefissi, err_strumentale):\n",
" cols = [col for col in campione.columns if col.startswith(prefix)]\n",
"\n",
" for i, row in campione.iterrows():\n",
" valori = row[cols].dropna().values.astype(float)\n",
" campione, rimossi = rimuovi_outlier(valori, err_strum)\n",
"\n",
" n = len(campione)\n",
" s = campione.std(ddof=1)\n",
" s = s / np.sqrt(n)\n",
" u = np.sqrt(s**2 + err_strum**2)\n",
"\n",
" analisi_stat.at[i, prefix] = campione.mean()\n",
" analisi_stat.at[i, f\"u{prefix}_strum\"] = err_strum\n",
" analisi_stat.at[i, f\"u{prefix}_stat\"] = s\n",
" analisi_stat.at[i, f\"u{prefix}\"] = u\n",
" analisi_stat.at[i, f\"n{prefix}\"] = n\n",
" analisi_stat.at[i, f\"out{prefix}\"] = rimossi\n",
"\n",
" return self\n",
"\n",
"\n",
"# Aggiunta a classe Data\n",
"Data.stat_chauv = stat_chauv"
]
},
{
"cell_type": "markdown",
"id": "86fcfbe5",
"metadata": {},
"source": [
"## Regressione lineare\n",
"y = Ax + By"
]
},
{
"cell_type": "markdown",
"id": "8e6a2c2e",
"metadata": {},
"source": [
"**data.reg_lin( stampa_param=True, plot_regressione=True, residui=True,** \n",
"&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;**x_label=\"\", y_label=\"\", r_label=\"\",** \n",
"&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;**titolo_reg=\"\", titolo_residui=\"\",** \n",
"&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&nbsp;**cd_A=4, cd_B=4, scala_barre=1 )** \n",
"\n",
"*input data.analisi_stat:*\n",
" - x, y: campioni x e y\n",
" - ux, uy: relative incertezze\n",
"\n",
"*input:*\n",
" - stampa_param: opzione stampa parametri regressione\n",
" - plot_regressione: opzione plot regressione lineare\n",
" - residui: opzione calcolo e plot residui\n",
" - x_label, y_label, r_label: etichette assi plot regressione e residui\n",
" - titolo_reg, titolo_residui: titolo plot regressione e residui\n",
" - cd_A, cd_B: cifre decimali visualizzazione parametri\n",
" - scala barre: scala ingrandimento barre di errore nella regressione\n",
"\n",
"*output param_reg:*\n",
" - A, B: parametri regressione\n",
" - uA, uB, covAB: relative incertezze e covarianze\n",
" - chi², P: chi quadro e relativa probabilità\n",
"\n",
"*output analisi_stat:*\n",
" - r, ur: residui e relativa incertezza"
]
},
{
"cell_type": "markdown",
"id": "6ccd1e25",
"metadata": {},
"source": [
"### Residui"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "7c815197",
"metadata": {},
"outputs": [],
"source": [
"# Plot residui\n",
" \n",
"def plot_residui(x, r,\n",
" ux, ur,\n",
" x_label, r_label, titolo):\n",
" \n",
" fig, ax = plt.subplots(figsize=(8, 5))\n",
"\n",
" # Residui con barre d'errore\n",
" ax.errorbar(\n",
" x, r,\n",
" xerr=ux, yerr=ur,\n",
" fmt='o', color=sns.color_palette()[0],\n",
" ecolor='gray', elinewidth=1, capsize=3,\n",
" markersize=5, label=\"Residui\"\n",
" )\n",
"\n",
" # Linea dello zero\n",
" ax.axhline(0, color='red', linestyle='--', linewidth=1)\n",
"\n",
" # Estetica\n",
" sns.despine(ax=ax)\n",
" ax.set_xlabel(x_label)\n",
" ax.set_ylabel(r_label)\n",
" ax.set_title(titolo)\n",
" ax.legend()\n",
" ax.grid(True, linestyle=':', linewidth=0.5, alpha=0.7)\n",
"\n",
" plt.tight_layout()\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "53ba0123",
"metadata": {},
"outputs": [],
"source": [
"# Calcolo residui\n",
"\n",
"def residui(analisi_stat,\n",
" A_num, B_num,\n",
" uA_num, uB_num, covAB_num):\n",
"\n",
" # Variabili simboliche\n",
" A, B, x, y = sp.symbols('A B x y', real=True)\n",
" uA, uB, ux, uy = sp.symbols('uA uB ux uy', positive=True)\n",
" covAB = sp.symbols('covAB', real=True)\n",
"\n",
" # Residuo: r = y - (Ax + B)\n",
" r = y - (A*x + B)\n",
"\n",
" # Propagazione errore (con covarianza A,B)\n",
" dr_dA = sp.diff(r, A)\n",
" dr_dB = sp.diff(r, B)\n",
" dr_dx = sp.diff(r, x)\n",
" dr_dy = sp.diff(r, y)\n",
"\n",
" u_r = sp.sqrt(\n",
" (dr_dA * uA)**2 +\n",
" (dr_dB * uB)**2 +\n",
" (dr_dx * ux)**2 +\n",
" (dr_dy * uy)**2 +\n",
" 2 * dr_dA * dr_dB * covAB\n",
" )\n",
"\n",
" # Funzioni numeriche\n",
" r_fn = sp.lambdify((x , y , A , B ), r, 'numpy')\n",
" u_r_fn = sp.lambdify(\n",
" (x , y , ux , uy , A , B , uA , uB , covAB ),\n",
" u_r , 'numpy'\n",
" )\n",
"\n",
" # Calcolo numerico\n",
" analisi_stat[\"r\"] = r_fn(\n",
" analisi_stat[\"x\"],\n",
" analisi_stat[\"y\"],\n",
" A_num,\n",
" B_num\n",
" )\n",
"\n",
" analisi_stat[\"ur\"] = u_r_fn(\n",
" analisi_stat[\"x\"], analisi_stat[\"y\"],\n",
" analisi_stat[\"ux\"], analisi_stat[\"uy\"],\n",
" A_num, B_num,\n",
" uA_num, uB_num, covAB_num\n",
" )\n",
"\n",
" return analisi_stat"
]
},
{
"cell_type": "markdown",
"id": "20b61f26",
"metadata": {},
"source": [
"### Regressione"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "299faa92",
"metadata": {},
"outputs": [],
"source": [
"# Plot regressione\n",
"\n",
"def plot_reg(x, y, ux, uy,\n",
" A, B, uA, uB, P,\n",
" x_label, y_label, titolo,\n",
" cd_A=4, cd_B=4, scala_barre=1):\n",
"\n",
" fig, ax = plt.subplots(figsize=(8, 5))\n",
"\n",
" x_fit = np.linspace(x.min(), x.max(), 300)\n",
" y_fit = A * x_fit + B\n",
"\n",
" ax.errorbar(\n",
" x, y,\n",
" xerr = scala_barre * ux,\n",
" yerr = scala_barre * uy,\n",
" fmt='o', color=sns.color_palette()[0],\n",
" ecolor='gray', elinewidth=1, capsize=3,\n",
" markersize=5, label=f\"Dati (barre errore x{scala_barre})\"\n",
" )\n",
" ax.plot(\n",
" x_fit, y_fit,\n",
" color='red', linewidth=1.5,\n",
" label = f\"$A={A:.{cd_A}f}\\\\pm{uA:.{cd_A}f}$\\n\"\n",
" f\"$B={B:.{cd_B}f}\\\\pm{uB:.{cd_B}f}$\\n\"\n",
" f\"$P(chi², ∞)={P:.4f}$\\n\"\n",
" )\n",
"\n",
" sns.despine(ax=ax)\n",
" ax.set_xlabel(x_label)\n",
" ax.set_ylabel(y_label)\n",
" ax.set_title(titolo)\n",
" ax.legend(fontsize=9)\n",
" ax.grid(True, linestyle=':', linewidth=0.5, alpha=0.7)\n",
"\n",
" plt.tight_layout()\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "9d3f0378",
"metadata": {},
"outputs": [],
"source": [
"# Funzioni regressione\n",
"\n",
"def uy_equiv(x, y, ux, uy):\n",
" \n",
" # Stima iniziale di A con sola uy\n",
" sy2 = uy**2\n",
" Sw = np.sum(1 / sy2)\n",
" Sx = np.sum(x / sy2)\n",
" Sxx = np.sum(x**2 / sy2)\n",
" Sy = np.sum(y / sy2)\n",
" Sxy = np.sum(x * y / sy2)\n",
" delta = Sxx * Sw - Sx**2\n",
" A_est = (Sxy * Sw - Sx * Sy) / delta\n",
"\n",
" # Propagazione\n",
" u_eq = np.sqrt(uy**2 + A_est**2 * ux**2)\n",
" return u_eq\n",
"\n",
"\n",
"def reg_lin(self,\n",
" stampa_param=True, plot_regressione=True, residui=True,\n",
" x_label=\"\", y_label=\"\", r_label=\"\",\n",
" titolo_reg=\"\", titolo_residui=\"\",\n",
" cd_A=4, cd_B=4, scala_barre=1):\n",
" \n",
" x = np.asarray(self.analisi_stat[\"x\"], dtype=float)\n",
" y = np.asarray(self.analisi_stat[\"y\"], dtype=float)\n",
" ux = np.asarray(self.analisi_stat[\"ux\"], dtype=float)\n",
" uy = np.asarray(self.analisi_stat[\"uy\"], dtype=float)\n",
"\n",
" # Propagazione errore x → y\n",
" uy_eq = uy_equiv(x, y, ux, uy)\n",
"\n",
" # Somme pesate\n",
" w = 1.0 / uy_eq**2\n",
" Sw = np.sum(w)\n",
" Sx = np.sum(w * x)\n",
" Sxx = np.sum(w * x**2)\n",
" Sy = np.sum(w * y)\n",
" Sxy = np.sum(w * x * y)\n",
" delta = Sxx * Sw - Sx**2\n",
"\n",
" # Parametri\n",
" A = (Sxy * Sw - Sx * Sy) / delta\n",
" B = (Sxx * Sy - Sxy * Sx) / delta\n",
" uA = np.sqrt(Sw / delta)\n",
" uB = np.sqrt(Sxx / delta)\n",
" covAB = -Sx / delta\n",
"\n",
" # Chi quadro\n",
" x2 = np.sum((y - A * x - B)**2 / uy_eq**2)\n",
" dof = len(x) - 2\n",
" P = stats.chi2.sf(x2, dof)\n",
"\n",
" # Raccolta parametri\n",
" self.param_reg[\"A\"] = A\n",
" self.param_reg[\"B\"] = B\n",
" self.param_reg[\"uA\"] = uA\n",
" self.param_reg[\"uB\"] = uB\n",
" self.param_reg[\"covAB\"] = covAB\n",
" self.param_reg[\"x2\"] = x2\n",
" self.param_reg[\"P\"] = P\n",
"\n",
" # Stampa\n",
" if stampa_param == True:\n",
" print(\"Ax + B : \")\n",
" print(f\"A = {A:.{cd_A}f} ± {uA:.{cd_A}f}\")\n",
" print(f\"B = {B:.{cd_B}f} ± {uB:.{cd_B}f}\")\n",
" print(f\"covAB = {covAB:.6f}\")\n",
" print(f\"chi² = {x2:.2f}\")\n",
" print(f\"P(chi², ∞) = {P:.2f}\")\n",
" \n",
" # Plot\n",
" if plot_regressione == True:\n",
" plot_reg(x, y, ux, uy,\n",
" A, B, uA, uB, P,\n",
" x_label, y_label, titolo_reg,\n",
" cd_A, cd_B, scala_barre)\n",
" \n",
" # Residui\n",
" if residui == True:\n",
" self = self.residui(A, B, uA, uB, covAB)\n",
" plot_residui(x, self.analisi_stat[\"r\"],\n",
" ux, self.analisi_stat[\"ur\"],\n",
" x_label, r_label, titolo_residui)\n",
"\n",
" return self\n",
"\n",
"\n",
"# Aggiunta a classe Data\n",
"Data.reg_lin = reg_lin"
]
},
{
"cell_type": "markdown",
"id": "b311d9e2",
"metadata": {},
"source": [
"# Plot gaussiane"
]
},
{
"cell_type": "markdown",
"id": "170849f1",
"metadata": {},
"source": [
"**plot_gauss( gaussiane )**\n",
"\n",
"*input gaussiane:* \n",
"[ (mi, sigma, colore label),... ]\n",
" - mi: valore medio (misura)\n",
" - sigma: deviazione standard (incertezza)\n",
" - colore: indice colore nella palette\n",
" - label: etichetta per la didascalia"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "f515a2bb",
"metadata": {},
"outputs": [],
"source": [
"def plot_gauss(gaussiane):\n",
" \n",
" # Creazione figura\n",
" plt.figure(figsize=(12, 7))\n",
"\n",
" # Creazione asse x\n",
" xMin = float('inf')\n",
" xMax = float('-inf')\n",
"\n",
" for mu, sigma, _, _ in gaussiane:\n",
" minimoLocale = mu - 4 * sigma\n",
" massimoLocale = mu + 4 * sigma\n",
" \n",
" if minimoLocale < xMin:\n",
" xMin = minimoLocale\n",
" \n",
" if massimoLocale > xMax:\n",
" xMax = massimoLocale\n",
" \n",
" x = np.linspace(xMin, xMax, 1000)\n",
"\n",
" # Ciclo gaussiane\n",
" for mu, sigma, colore, etichetta in gaussiane:\n",
" y = stats.norm.pdf(x, mu, sigma)\n",
" plt.plot(x, y, color=sns.color_palette()[colore], linewidth=1, label=etichetta)\n",
" \n",
" puntiLinee = [mu - sigma, mu, mu + sigma]\n",
" for px in puntiLinee:\n",
" py = stats.norm.pdf(px, mu, sigma) \n",
" plt.vlines(x=px,\n",
" ymin=0, ymax=py,\n",
" colors=sns.color_palette()[colore],\n",
" linestyles='dashed', linewidth=1)\n",
" \n",
" # Dettagli estetici finali\n",
" plt.ylim(bottom=0)\n",
" plt.title('Confronto dati')\n",
" plt.xlabel('k')\n",
" plt.legend()\n",
"\n",
" # Mostriamo il grafico\n",
" plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"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.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "e7f6f9db",
"metadata": {},
"outputs": [],
@@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "e31f5b72",
"metadata": {},
"outputs": [],
@@ -48,10 +48,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "a88eb843",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(np.float64(1.162476387438193), -1)\n"
]
}
],
"source": [
"def compatibilita(x1, x2, u1, u2):\n",
" diff = x1 - x2\n",
@@ -79,7 +87,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 14,
"id": "3d561eb0",
"metadata": {},
"outputs": [
@@ -134,10 +142,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "ffdeea69",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"media pesata: 10.885245901639344\n",
"sigma: 0.15364425591947517\n"
]
}
],
"source": [
"\n",
"def mediaPesata(x, ux, dim = 0):\n",
@@ -185,10 +202,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "2c4561c9",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Maschera: [False False True False False False False False False]\n",
"Outlier: [50.]\n",
"NP: [6.26782319 7.07278344 0.37856532 6.66695415 nan 7.48227073\n",
" 5.87724449 5.44192616 3.56273523]\n"
]
}
],
"source": [
"def outlier_t(x, ux, dim=0):\n",
" # Conversione posizionale\n",
@@ -261,19 +289,19 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 8,
"id": "78c30380",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'pd' is not defined",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mNameError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 49\u001b[39m\n\u001b[32m 45\u001b[39m chi = sc.stats.chi2.cdf(x2, dof) \u001b[38;5;66;03m# P(X² > x2)\u001b[39;00m\n\u001b[32m 47\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m A, B, sigma_A, sigma_B, cov_AB, chi\n\u001b[32m---> \u001b[39m\u001b[32m49\u001b[39m df = \u001b[43mpd\u001b[49m.DataFrame({\n\u001b[32m 50\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mx\u001b[39m\u001b[33m\"\u001b[39m:[\u001b[32m1.0\u001b[39m, \u001b[32m2.0\u001b[39m, \u001b[32m3.0\u001b[39m, \u001b[32m4.0\u001b[39m, \u001b[32m5.0\u001b[39m],\n\u001b[32m 51\u001b[39m \u001b[33m\"\u001b[39m\u001b[33my\u001b[39m\u001b[33m\"\u001b[39m:[\u001b[32m2.1\u001b[39m, \u001b[32m3.9\u001b[39m, \u001b[32m6.2\u001b[39m, \u001b[32m7.8\u001b[39m, \u001b[32m10.1\u001b[39m],\n\u001b[32m 52\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mux\u001b[39m\u001b[33m\"\u001b[39m:[\u001b[32m0.1\u001b[39m, \u001b[32m0.1\u001b[39m, \u001b[32m0.1\u001b[39m, \u001b[32m0.1\u001b[39m, \u001b[32m0.1\u001b[39m],\n\u001b[32m 53\u001b[39m \u001b[33m\"\u001b[39m\u001b[33muy\u001b[39m\u001b[33m\"\u001b[39m:[\u001b[32m0.2\u001b[39m, \u001b[32m0.2\u001b[39m, \u001b[32m0.2\u001b[39m, \u001b[32m0.2\u001b[39m, \u001b[32m0.2\u001b[39m]\n\u001b[32m 54\u001b[39m })\n\u001b[32m 56\u001b[39m A, B, sA, sB, covAB, chi = reg_lin(df[\u001b[33m\"\u001b[39m\u001b[33mx\u001b[39m\u001b[33m\"\u001b[39m], df[\u001b[33m\"\u001b[39m\u001b[33my\u001b[39m\u001b[33m\"\u001b[39m], df[\u001b[33m\"\u001b[39m\u001b[33mux\u001b[39m\u001b[33m\"\u001b[39m], df[\u001b[33m\"\u001b[39m\u001b[33muy\u001b[39m\u001b[33m\"\u001b[39m])\n\u001b[32m 57\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33m\"\u001b[39m\u001b[33mAx + B : \u001b[39m\u001b[33m\"\u001b[39m)\n",
"\u001b[31mNameError\u001b[39m: name 'pd' is not defined"
"name": "stdout",
"output_type": "stream",
"text": [
"Ax + B : \n",
"A = 1.9900 +- 0.0892\n",
"B = 0.0500 +- 0.2959\n",
"cov_AB = -0.023880\n",
"p-value chi² = 0.2813\n"
]
}
],
@@ -346,7 +374,7 @@
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": "base",
"language": "python",
"name": "python3"
},
@@ -360,7 +388,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.5"
"version": "3.13.11"
}
},
"nbformat": 4,

BIN
mollaDefinitiva/k molle.ods Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
m1,m2,m3,dx1,dx2,dx3,dx4,dx5,dx6
88.97,88.97,88.96,77.26,77.28,77.26,77.28,77.24,77.42
108.61,108.61,108.61,68.92,68.94,69.00,68.98,68.90,69.02
128.64,128.63,128.64,60.88,61.00,60.82,60.94,61.08,60.94
148.38,148.38,148.38,52.96,52.96,52.78,52.88,52.88,53.00
168.53,168.53,168.53,44.42,44.68,44.48,44.80,44.92,44.52
1 m1 m2 m3 dx1 dx2 dx3 dx4 dx5 dx6
2 88.97 88.97 88.96 77.26 77.28 77.26 77.28 77.24 77.42
3 108.61 108.61 108.61 68.92 68.94 69.00 68.98 68.90 69.02
4 128.64 128.63 128.64 60.88 61.00 60.82 60.94 61.08 60.94
5 148.38 148.38 148.38 52.96 52.96 52.78 52.88 52.88 53.00
6 168.53 168.53 168.53 44.42 44.68 44.48 44.80 44.92 44.52

View File

@@ -0,0 +1,5 @@
m1,m2,m3,a1,ua1,w1,uw1,c1,uc1,a2,ua2,w2,uw2,c2,uc2,alp,ualp
108.61,108.61,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,0.333333,0.000001
128.64,128.63,128.64,10.037,0.025,13.1939,0.0007,259.605,0.018,9.744,0.027,13.1913,0.0009,259.745,0.02,0.333333,0.000001
148.38,148.38,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,0.333333,0.000001
168.53,168.53,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,0.333333,0.000001
1 m1 m2 m3 a1 ua1 w1 uw1 c1 uc1 a2 ua2 w2 uw2 c2 uc2 alp ualp
2 108.61 108.61 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 0.333333 0.000001
3 128.64 128.63 128.64 10.037 0.025 13.1939 0.0007 259.605 0.018 9.744 0.027 13.1913 0.0009 259.745 0.02 0.333333 0.000001
4 148.38 148.38 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 0.333333 0.000001
5 168.53 168.53 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 0.333333 0.000001

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,5 @@
m1,m2,m3,dx1,dx2,dx3,dx4,dx5,dx6
49.25,49.24,49.25,212.10,211.64,212.00,212.18,212.52,212.04
69.28,69.28,69.27,150.92,150.26,150.02,150.16,150.40,150.18
88.97,88.97,88.96,90.34,90.34,90.38,90.52,90.26,90.28
108.61,108.61,108.61,29.82,30.18,30.10,30.20,30.10,30.40
1 m1 m2 m3 dx1 dx2 dx3 dx4 dx5 dx6
2 49.25 49.24 49.25 212.10 211.64 212.00 212.18 212.52 212.04
3 69.28 69.28 69.27 150.92 150.26 150.02 150.16 150.40 150.18
4 88.97 88.97 88.96 90.34 90.34 90.38 90.52 90.26 90.28
5 108.61 108.61 108.61 29.82 30.18 30.10 30.20 30.10 30.40

View File

@@ -0,0 +1,6 @@
m1,m2,m3,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,alp,ualp
49.25,49.24,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,0.333333,0.000001
69.28,69.28,69.27,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,0.333333,0.000001
88.97,88.97,88.96,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,0.333333,0.000001
108.61,108.61,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,0.333333,0.000001
128.64,128.63,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,0.333333,0.000001
1 m1 m2 m3 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 alp ualp
2 49.25 49.24 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 0.333333 0.000001
3 69.28 69.28 69.27 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 0.333333 0.000001
4 88.97 88.97 88.96 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 0.333333 0.000001
5 108.61 108.61 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 0.333333 0.000001
6 128.64 128.63 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 0.333333 0.000001