From a4eb95baf41a891e3cadb8669d5352a412c5df6f Mon Sep 17 00:00:00 2001 From: dwenz Date: Thu, 31 Oct 2019 13:56:21 +0100 Subject: [PATCH] Corrected error in the chi-square calculation. --- ...l_1._Einstieg_in_die_Welt_von_Python.ipynb | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Kapitel_1._Einstieg_in_die_Welt_von_Python.ipynb b/Kapitel_1._Einstieg_in_die_Welt_von_Python.ipynb index 7100af0..ff74a22 100644 --- a/Kapitel_1._Einstieg_in_die_Welt_von_Python.ipynb +++ b/Kapitel_1._Einstieg_in_die_Welt_von_Python.ipynb @@ -2632,7 +2632,6 @@ " # wir in der Regel absolute und keine relativen \n", " # Unsicherheiten messen.\n", " )\n", - "\n", "plt.errorbar(strom, \n", " spannung,\n", " xerr=strom_error,\n", @@ -2682,11 +2681,11 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 84, "metadata": { "ExecuteTime": { - "end_time": "2019-10-31T12:32:15.057094Z", - "start_time": "2019-10-31T12:32:15.041472Z" + "end_time": "2019-10-31T12:54:51.185843Z", + "start_time": "2019-10-31T12:54:51.152000Z" } }, "outputs": [ @@ -2694,14 +2693,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "Das chi-qudrat ist 506\n" + "Das chi-qudrat ist 1.26\n" ] } ], "source": [ - "chi_2 = [ (u - Spannung(I, para2[0])/du)**2 for I,u,du in zip(strom, spannung, spannung_error)]\n", + "chi_2 = [ (u - Spannung(i, para2[0]))**2/du**2 for i,u,du in zip(strom, spannung, spannung_error)]\n", "chi_2 = sum(chi_2)\n", - "print(f'Das chi-qudrat ist {chi_2:.0f}')" + "print(f'Das chi-qudrat ist {chi_2:.2f}')" ] }, { @@ -2710,18 +2709,18 @@ "source": [ "Wie vergleicht sich dieses $\\chi^2$ nun mit einer Funktion welche unsere Daten schlechter beschreibt. Zum Beispiel sofern wir die Spannung über die Funktion \n", "\n", - "$$ U(R,I) = R \\cdot I + C $$\n", + "$$ U(R,I) = R \\cdot I^2 $$\n", "\n", - "beschreiben würden, also zusätzlich einem konstantem Offset." + "beschreiben würden." ] }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 88, "metadata": { "ExecuteTime": { - "end_time": "2019-10-31T12:32:15.088340Z", - "start_time": "2019-10-31T12:32:15.057094Z" + "end_time": "2019-10-31T12:55:52.889042Z", + "start_time": "2019-10-31T12:55:52.873421Z" } }, "outputs": [ @@ -2729,14 +2728,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "Chi-qudrat nach URI: 506\n", - "Chi-qudrat nach URIC: 506\n" + "Chi-qudrat nach URI: 1.26\n", + "Chi-qudrat nach URI-Parabel: 60.68\n" ] } ], "source": [ - "def Spannung2(I, R, C):\n", - " return R * I + C \n", + "def Spannung2(I, R):\n", + " return R * I**2\n", "\n", "\n", "\n", @@ -2747,9 +2746,9 @@ " absolute_sigma=True \n", " )\n", "\n", - "chi_2_new = [ (u - Spannung2(I, *para3)/du)**2 for I,u,du in zip(strom, spannung, spannung_error)]\n", + "chi_2_new = [ (u - Spannung2(I, *para3))**2/du**2 for I,u,du in zip(strom, spannung, spannung_error)]\n", "chi_2_new = sum(chi_2_new)\n", - "print(f'Chi-qudrat nach URI: {chi_2:.0f}\\nChi-qudrat nach URIC: {chi_2_new:.0f}')" + "print(f'Chi-qudrat nach URI: {chi_2:.2f}\\nChi-qudrat nach URI-Parabel: {chi_2_new:.2f}')" ] }, {