<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?action=history&amp;feed=atom&amp;title=KADD_2022_Laboratorium_11_EN</id>
		<title>KADD 2022 Laboratorium 11 EN - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?action=history&amp;feed=atom&amp;title=KADD_2022_Laboratorium_11_EN"/>
		<link rel="alternate" type="text/html" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_11_EN&amp;action=history"/>
		<updated>2026-05-14T08:22:49Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.5</generator>

	<entry>
		<id>http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_11_EN&amp;diff=2947&amp;oldid=prev</id>
		<title>Lgraczyk at 11:48, 23 May 2022</title>
		<link rel="alternate" type="text/html" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_11_EN&amp;diff=2947&amp;oldid=prev"/>
				<updated>2022-05-23T11:48:05Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: white; color:black;&quot;&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 11:48, 23 May 2022&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Using the least-squares method, fit to the data polynomials of varying degrees &amp;lt;code&amp;gt;n=0..5&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Using the least-squares method, fit to the data polynomials of varying degrees &amp;lt;code&amp;gt;n=0..5&amp;lt;/code&amp;gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Please read data from the following [http://www.if.pw.edu.pl/~lgraczyk/KADD2016/lab11/dane.dat file]. They come from the experiment of elastic collisions of negatively charged K mesons (kaons) with protons, at constant K meson energy.&amp;nbsp; In the first column there are values of the cosine of the scattering angle in the rest mass reference frame, in the second column is the corresponding number of collisions. As errors please assume the square root of the number of observations. The degree of&amp;nbsp; fitted polynomial allows to calculate &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;sge&amp;nbsp; Jeżeli otrzymany rozkład&amp;nbsp; ma postać wielomianu, to wyznaczenie jego stopnia umożliwia wyznaczenie spinowych liczb kwantowych występujących stanów pośrednich &lt;/del&gt;(&amp;quot;Analiza danych&amp;quot;, S.Brandt, Przykład 9.2.).&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* Please read data from the following [http://www.if.pw.edu.pl/~lgraczyk/KADD2016/lab11/dane.dat file]. They come from the experiment of elastic collisions of negatively charged K mesons (kaons) with protons, at constant K meson energy.&amp;nbsp; In the first column there are values of the cosine of the scattering angle in the rest mass reference frame, in the second column is the corresponding number of collisions. As errors please assume the square root of the number of observations. The degree of&amp;nbsp; fitted polynomial allows to calculate &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;the spin quantum numbers of intermediate stages &lt;/ins&gt;(&amp;quot;Analiza danych&amp;quot;, S.Brandt, Przykład 9.2.).&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Proszę zaimplementować funkcję realizującą procedurę dopasowania metodą najmniejszych kwadratów&lt;/del&gt;. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;W tym celu należy wykorzystać wzory &lt;/del&gt;(ich wyprowadzenie znajduje się w [http://www.if.pw.edu.pl/~lgraczyk/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;KADD2019&lt;/del&gt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Wyklad12&lt;/del&gt;-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;2019&lt;/del&gt;.pdf &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;wykładzie &lt;/del&gt;12] &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;(od slajdu 22) oraz w &lt;/del&gt;[http://www.if.pw.edu.pl/~majanik/files/wiel.ps instrukcji]) - '''&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;proszę dokładnie przeczytać tę instrukcję &lt;/del&gt;- &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;zadanie robimy zgodnie z nią&lt;/del&gt;''':&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Please implement the function realizing the least-squares method&lt;/ins&gt;. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Use formulas from the lecture &lt;/ins&gt;(ich wyprowadzenie znajduje się w [http://www.if.pw.edu.pl/~lgraczyk/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;KADD2022&lt;/ins&gt;/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Wyklad11&lt;/ins&gt;-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;2022&lt;/ins&gt;.pdf &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Lecture &lt;/ins&gt;12] &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and from the unstruction &lt;/ins&gt;[http://www.if.pw.edu.pl/~majanik/files/wiel.ps instrukcji]) - '''&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;please carefully read the instruction &lt;/ins&gt;- &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;all the steps should follow the instruction&lt;/ins&gt;''':&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[File:wzor1_new_asd.png]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[File:wzor1_new_asd.png]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[File:wzor89.png]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[File:wzor89.png]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;''&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Komentarz&lt;/del&gt;'': &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;szukamy &lt;/del&gt;minimum &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;funkcji &lt;/del&gt;M (&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;odpowiednik statystyki &lt;/del&gt;chi-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;kwadrat&lt;/del&gt;), &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;wartości &lt;/del&gt;&amp;lt;code&amp;gt;t_{j}&amp;lt;/code&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;to cosinusy kąta rozproszenia &lt;/del&gt;(&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;pierwsza kolumna pliku&lt;/del&gt;), &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;wartości &lt;/del&gt;&amp;lt;code&amp;gt;y_{j}&amp;lt;/code&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;to liczby obserwacji &lt;/del&gt;(&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;druga kolumna&lt;/del&gt;). &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Estymatory &lt;/del&gt;&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;to poszukiwane współczynniki wielomianu&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;''&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Comment&lt;/ins&gt;'': &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;we search from a &lt;/ins&gt;minimum &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;of &lt;/ins&gt;M &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;function &lt;/ins&gt;(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;equivalent of &lt;/ins&gt;chi-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;squared statistics&lt;/ins&gt;), &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;values &lt;/ins&gt;&amp;lt;code&amp;gt;t_{j}&amp;lt;/code&amp;gt; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are the cosine scattering functions &lt;/ins&gt;(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;first column from the file&lt;/ins&gt;), &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;values &lt;/ins&gt;&amp;lt;code&amp;gt;y_{j}&amp;lt;/code&amp;gt; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are the observations numbers &lt;/ins&gt;(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;second column&lt;/ins&gt;). &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Estimators &lt;/ins&gt;&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;are the searched parameters (coefficients) of the polynomial&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Przykładowy nagłówek funkcji&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Example function definition&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; // &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Funkcja zwraca wartosc funkcji &lt;/del&gt;M&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; // &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Function returns &lt;/ins&gt;M&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; // &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;parametry&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; // &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;parameters&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; st - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;stopien dopasowanego wielomianu&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; st - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;degree of the polynomial&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; n - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;liczba pomiarow&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; n - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;number of measurements&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; tj - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;tablica cosinusow kata rozproszenia&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; tj - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;array of cosine of scattering angles&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; yj - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;wyniki pomiarow&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; yj - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;measurement results&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; sigmaj - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;bledy pomiarow&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; sigmaj - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;measurement errors&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; wsp - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;tablica do ktorej nalezy wpisac wartosci wyznaczonych wspolczynnikow &lt;/del&gt;([[File:wzor10.png]])&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; wsp - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;array in which we need to save estimated coefficients &lt;/ins&gt;([[File:wzor10.png]])&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; bswp - &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;tablica do ktorej nalezy wpisac bledy wyznaczonych wspolczynnikow &lt;/del&gt;(&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;pierwiastki kwadratowe z elementów diagonalnych macierzy &lt;/del&gt; [[File:wzor11.png]])&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; //&amp;nbsp; bswp - &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;array in which we need to save estimated coefficient errors &lt;/ins&gt;(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;square roots of the diagonal elements of the matrix &lt;/ins&gt; [[File:wzor11.png]])&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; double &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;dopasuj &lt;/del&gt;(int st, int n, double *tj, double *yj, double *sigmaj, double *wsp, double *bwsp);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; double &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;fit &lt;/ins&gt;(int st, int n, double *tj, double *yj, double *sigmaj, double *wsp, double *bwsp);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Do zaimplementowania powyższych wzorów wygodnie jest skorzystać z klasy &lt;/del&gt;[http://www.slac.stanford.edu/comp/unix/package/cernroot/30106/TMatrixD.html TMatrixD]. &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Przykłady jej użycia&lt;/del&gt;:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;To implement the formulas please use the class &lt;/ins&gt;[http://www.slac.stanford.edu/comp/unix/package/cernroot/30106/TMatrixD.html TMatrixD]. &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Examples&lt;/ins&gt;:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; // utworzenie macierzy o wymiarach n x m&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; // utworzenie macierzy o wymiarach n x m&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 51:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 51:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; macierz-&amp;gt;Invert();&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;nbsp; macierz-&amp;gt;Invert();&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Proszę zinterpretować otrzymane dopasowania przeprowadzając test &lt;/del&gt;chi-&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;kwadrat &lt;/del&gt;(&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;korzystając z wyznaczonej wartości funkcji &lt;/del&gt;M). &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Należy określić stopień wielomianu&lt;/del&gt;, &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;dla którego dopasowanie jest najlepsze oraz wyznaczyć najmniejszy stopień wielomianu, którego nie możemy odrzucić. Proszę wypisać wartości wyznaczonych współczynników wielomianu.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Please interpret the resulting fitting by performing a &lt;/ins&gt;chi-&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;squared test &lt;/ins&gt;(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;using the &lt;/ins&gt;M &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;functions&lt;/ins&gt;). &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Please state which degree of the polynomial fits data best (what is the lowest degree of the polynomial&lt;/ins&gt;, &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;for which we do not reject the null hypothesis)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;-&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Wynik &lt;/del&gt;==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;== &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Result &lt;/ins&gt;==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[File:mnk_2.png]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[File:mnk_2.png]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lgraczyk</name></author>	</entry>

	<entry>
		<id>http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_11_EN&amp;diff=2946&amp;oldid=prev</id>
		<title>Lgraczyk: Created page with &quot;== Zadanie == '''Least-squares method''' (5 pkt.)  Using the least-squares method, fit to the data polynomials of varying degrees &lt;code&gt;n=0..5&lt;/code&gt;.  * Please read data from th...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_11_EN&amp;diff=2946&amp;oldid=prev"/>
				<updated>2022-05-23T11:24:05Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Zadanie == &amp;#39;&amp;#39;&amp;#39;Least-squares method&amp;#39;&amp;#39;&amp;#39; (5 pkt.)  Using the least-squares method, fit to the data polynomials of varying degrees &amp;lt;code&amp;gt;n=0..5&amp;lt;/code&amp;gt;.  * Please read data from th...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Zadanie ==&lt;br /&gt;
'''Least-squares method''' (5 pkt.)&lt;br /&gt;
&lt;br /&gt;
Using the least-squares method, fit to the data polynomials of varying degrees &amp;lt;code&amp;gt;n=0..5&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Please read data from the following [http://www.if.pw.edu.pl/~lgraczyk/KADD2016/lab11/dane.dat file]. They come from the experiment of elastic collisions of negatively charged K mesons (kaons) with protons, at constant K meson energy.  In the first column there are values of the cosine of the scattering angle in the rest mass reference frame, in the second column is the corresponding number of collisions. As errors please assume the square root of the number of observations. The degree of  fitted polynomial allows to calculate sge  Jeżeli otrzymany rozkład  ma postać wielomianu, to wyznaczenie jego stopnia umożliwia wyznaczenie spinowych liczb kwantowych występujących stanów pośrednich (&amp;quot;Analiza danych&amp;quot;, S.Brandt, Przykład 9.2.).&lt;br /&gt;
&lt;br /&gt;
* Proszę zaimplementować funkcję realizującą procedurę dopasowania metodą najmniejszych kwadratów. W tym celu należy wykorzystać wzory (ich wyprowadzenie znajduje się w [http://www.if.pw.edu.pl/~lgraczyk/KADD2019/Wyklad12-2019.pdf wykładzie 12] (od slajdu 22) oraz w [http://www.if.pw.edu.pl/~majanik/files/wiel.ps instrukcji]) - '''proszę dokładnie przeczytać tę instrukcję - zadanie robimy zgodnie z nią''':&lt;br /&gt;
&lt;br /&gt;
[[File:wzor1_new_asd.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:wzor2.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:wzor3.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:wzor4.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:wzor567.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:wzor89.png]]&lt;br /&gt;
&lt;br /&gt;
''Komentarz'': szukamy minimum funkcji M (odpowiednik statystyki chi-kwadrat), wartości &amp;lt;code&amp;gt;t_{j}&amp;lt;/code&amp;gt; to cosinusy kąta rozproszenia (pierwsza kolumna pliku), wartości &amp;lt;code&amp;gt;y_{j}&amp;lt;/code&amp;gt; to liczby obserwacji (druga kolumna). Estymatory &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; to poszukiwane współczynniki wielomianu.&lt;br /&gt;
&lt;br /&gt;
Przykładowy nagłówek funkcji:&lt;br /&gt;
 // Funkcja zwraca wartosc funkcji M&lt;br /&gt;
 // parametry:&lt;br /&gt;
 //  st - stopien dopasowanego wielomianu&lt;br /&gt;
 //  n - liczba pomiarow&lt;br /&gt;
 //  tj - tablica cosinusow kata rozproszenia&lt;br /&gt;
 //  yj - wyniki pomiarow&lt;br /&gt;
 //  sigmaj - bledy pomiarow&lt;br /&gt;
 //  wsp - tablica do ktorej nalezy wpisac wartosci wyznaczonych wspolczynnikow ([[File:wzor10.png]])&lt;br /&gt;
 //  bswp - tablica do ktorej nalezy wpisac bledy wyznaczonych wspolczynnikow (pierwiastki kwadratowe z elementów diagonalnych macierzy  [[File:wzor11.png]])&lt;br /&gt;
 double dopasuj (int st, int n, double *tj, double *yj, double *sigmaj, double *wsp, double *bwsp);&lt;br /&gt;
&lt;br /&gt;
Do zaimplementowania powyższych wzorów wygodnie jest skorzystać z klasy [http://www.slac.stanford.edu/comp/unix/package/cernroot/30106/TMatrixD.html TMatrixD]. Przykłady jej użycia:&lt;br /&gt;
&lt;br /&gt;
 // utworzenie macierzy o wymiarach n x m&lt;br /&gt;
 TMatrixD *macierzA = new TMatrixD(n,m);&lt;br /&gt;
&lt;br /&gt;
 // dostep do elementu o indeksach i,j macierzy macierzA, np.:&lt;br /&gt;
 (*macierzA)(i,j) = 1;&lt;br /&gt;
&lt;br /&gt;
 // mnozenie macierzy: macierzA = macierzB macierzC&lt;br /&gt;
 TMatrixD *macierzA = new TMatrixD(*macierzB, TMatrix::kMult, *macierzC);&lt;br /&gt;
&lt;br /&gt;
 // transponowanie macierzy&lt;br /&gt;
 TMatrixD *macierzAt = new TMatrixD(TMatrix::kTransposed,*macierzA);&lt;br /&gt;
&lt;br /&gt;
 // odwracanie macierzy&lt;br /&gt;
 macierz-&amp;gt;Invert();&lt;br /&gt;
&lt;br /&gt;
* Proszę zinterpretować otrzymane dopasowania przeprowadzając test chi-kwadrat (korzystając z wyznaczonej wartości funkcji M). Należy określić stopień wielomianu, dla którego dopasowanie jest najlepsze oraz wyznaczyć najmniejszy stopień wielomianu, którego nie możemy odrzucić. Proszę wypisać wartości wyznaczonych współczynników wielomianu.&lt;br /&gt;
&lt;br /&gt;
== Wynik ==&lt;br /&gt;
&lt;br /&gt;
[[File:mnk_2.png]]&lt;br /&gt;
&lt;br /&gt;
 Output:&lt;br /&gt;
&lt;br /&gt;
  Dopasowanie wielomianem stopnia 0&lt;br /&gt;
  M = 833.548&lt;br /&gt;
  x0 = 57.8452 +- 2.4051&lt;br /&gt;
  Liczba stopni swobody=9&lt;br /&gt;
  Kwantyl=21.666&lt;br /&gt;
  Poziom istotnosci=0.01&lt;br /&gt;
  Stopien 0: odrzucamy&lt;br /&gt;
&lt;br /&gt;
  Dopasowanie wielomianem stopnia 1&lt;br /&gt;
  M = 585.449&lt;br /&gt;
  x0 = 82.6551 +- 2.87498&lt;br /&gt;
  x1 = 99.0998 +- 6.29159&lt;br /&gt;
  Liczba stopni swobody=8&lt;br /&gt;
  Kwantyl=20.0902&lt;br /&gt;
  Poziom istotnosci=0.01&lt;br /&gt;
  Stopien 1: odrzucamy&lt;br /&gt;
&lt;br /&gt;
  Dopasowanie wielomianem stopnia 2&lt;br /&gt;
  M = 36.4096&lt;br /&gt;
  x0 = 47.267 +- 3.24753&lt;br /&gt;
  x1 = 185.955 +- 7.30235&lt;br /&gt;
  x2 = 273.612 +- 11.6771&lt;br /&gt;
  Liczba stopni swobody=7&lt;br /&gt;
  Kwantyl=18.4753&lt;br /&gt;
  Poziom istotnosci=0.01&lt;br /&gt;
  Stopien 2: odrzucamy&lt;br /&gt;
&lt;br /&gt;
  Dopasowanie wielomianem stopnia 3&lt;br /&gt;
  M = 2.84989&lt;br /&gt;
  x0 = 37.949 +- 3.62403&lt;br /&gt;
  x1 = 126.546 +- 12.5894&lt;br /&gt;
  x2 = 312.018 +- 13.4278&lt;br /&gt;
  x3 = 137.585 +- 23.7499&lt;br /&gt;
  Liczba stopni swobody=6&lt;br /&gt;
  Kwantyl=16.8119&lt;br /&gt;
  Poziom istotnosci=0.01&lt;br /&gt;
  Stopien 3: akceptujemy&lt;br /&gt;
&lt;br /&gt;
  Dopasowanie wielomianem stopnia 4&lt;br /&gt;
  M = 1.68602&lt;br /&gt;
  x0 = 39.6179 +- 3.94036&lt;br /&gt;
  x1 = 119.102 +- 14.3563&lt;br /&gt;
  x2 = 276.49 +- 35.5643&lt;br /&gt;
  x3 = 151.91 +- 27.2096&lt;br /&gt;
  x4 = 52.5999 +- 48.7566&lt;br /&gt;
  Liczba stopni swobody=5&lt;br /&gt;
  Kwantyl=15.0863&lt;br /&gt;
  Poziom istotnosci=0.01&lt;br /&gt;
  Stopien 4: akceptujemy&lt;br /&gt;
&lt;br /&gt;
  Dopasowanie wielomianem stopnia 5&lt;br /&gt;
  M = 1.66265&lt;br /&gt;
  x0 = 39.8786 +- 4.29351&lt;br /&gt;
  x1 = 121.384 +- 20.7054&lt;br /&gt;
  x2 = 273.188 +- 41.6103&lt;br /&gt;
  x3 = 136.571 +- 103.954&lt;br /&gt;
  x4 = 56.8995 +- 56.2858&lt;br /&gt;
  x5 = 16.7294 +- 109.424&lt;br /&gt;
  Liczba stopni swobody=4&lt;br /&gt;
  Kwantyl=13.2767&lt;br /&gt;
  Poziom istotnosci=0.01&lt;br /&gt;
  Stopien 5: akceptujemy&lt;/div&gt;</summary>
		<author><name>Lgraczyk</name></author>	</entry>

	</feed>