<?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_5_EN</id>
		<title>KADD 2022 Laboratorium 5 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_5_EN"/>
		<link rel="alternate" type="text/html" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_5_EN&amp;action=history"/>
		<updated>2026-04-06T09:23:39Z</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_5_EN&amp;diff=2886&amp;oldid=prev</id>
		<title>Lgraczyk: /* Exercise */</title>
		<link rel="alternate" type="text/html" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_5_EN&amp;diff=2886&amp;oldid=prev"/>
				<updated>2022-03-28T10:48:31Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Exercise&lt;/span&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 10:48, 28 March 2022&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&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;== Exercise ==&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;== Exercise ==&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;div&gt;Measurements of three physical observables&amp;nbsp; &amp;lt;code&amp;gt;X1, X2&amp;lt;/code&amp;gt; oraz &amp;lt;code&amp;gt;X3&amp;lt;/code&amp;gt; have been made. Results of the measurements are in the following files:&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;Measurements of three physical observables&amp;nbsp; &amp;lt;code&amp;gt;X1, X2&amp;lt;/code&amp;gt; oraz &amp;lt;code&amp;gt;X3&amp;lt;/code&amp;gt; have been made. Results of the measurements are in the following files:&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; [http://www.if.pw.edu.pl/~lgraczyk/wiki/images/e/ed/Dane1.dat Dane1.dat], [http://www.if.pw.edu.pl/~lgraczyk/wiki/images/0/0d/Dane2.dat Dane2.dat] &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;oraz &lt;/del&gt;[http://www.if.pw.edu.pl/~lgraczyk/wiki/images/b/ba/Dane3.dat Dane3.dat].&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; [http://www.if.pw.edu.pl/~lgraczyk/wiki/images/e/ed/Dane1.dat Dane1.dat], [http://www.if.pw.edu.pl/~lgraczyk/wiki/images/0/0d/Dane2.dat Dane2.dat] &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;and &lt;/ins&gt;[http://www.if.pw.edu.pl/~lgraczyk/wiki/images/b/ba/Dane3.dat Dane3.dat].&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;* Please calculate the result (mean and uncertainty - standard deviation) and draw the relation between the variables &amp;lt;code&amp;gt;(X1, X2)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(X2, X3)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;(X1, X3)&amp;lt;/code&amp;gt;. (1 pkt)&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;* Please calculate the result (mean and uncertainty - standard deviation) and draw the relation between the variables &amp;lt;code&amp;gt;(X1, X2)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(X2, X3)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;(X1, X3)&amp;lt;/code&amp;gt;. (1 pkt)&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_5_EN&amp;diff=2885&amp;oldid=prev</id>
		<title>Lgraczyk: Created page with &quot;{| align=&quot;right&quot; | __TOC__ |}   == Exercise == Measurements of three physical observables  &lt;code&gt;X1, X2&lt;/code&gt; oraz &lt;code&gt;X3&lt;/code&gt; have been made. Results of the measurements ar...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.if.pw.edu.pl/~lgraczyk/wiki/index.php?title=KADD_2022_Laboratorium_5_EN&amp;diff=2885&amp;oldid=prev"/>
				<updated>2022-03-28T10:48:13Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{| align=&amp;quot;right&amp;quot; | __TOC__ |}   == Exercise == Measurements of three physical observables  &amp;lt;code&amp;gt;X1, X2&amp;lt;/code&amp;gt; oraz &amp;lt;code&amp;gt;X3&amp;lt;/code&amp;gt; have been made. Results of the measurements ar...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| align=&amp;quot;right&amp;quot;&lt;br /&gt;
| __TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exercise ==&lt;br /&gt;
Measurements of three physical observables  &amp;lt;code&amp;gt;X1, X2&amp;lt;/code&amp;gt; oraz &amp;lt;code&amp;gt;X3&amp;lt;/code&amp;gt; have been made. Results of the measurements are in the following files:&lt;br /&gt;
 [http://www.if.pw.edu.pl/~lgraczyk/wiki/images/e/ed/Dane1.dat Dane1.dat], [http://www.if.pw.edu.pl/~lgraczyk/wiki/images/0/0d/Dane2.dat Dane2.dat] oraz [http://www.if.pw.edu.pl/~lgraczyk/wiki/images/b/ba/Dane3.dat Dane3.dat].&lt;br /&gt;
&lt;br /&gt;
* Please calculate the result (mean and uncertainty - standard deviation) and draw the relation between the variables &amp;lt;code&amp;gt;(X1, X2)&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;(X2, X3)&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;(X1, X3)&amp;lt;/code&amp;gt;. (1 pkt)&lt;br /&gt;
&lt;br /&gt;
Variables &amp;lt;code&amp;gt;Y1, Y2&amp;lt;/code&amp;gt; are related to &amp;lt;code&amp;gt;X1, X2, X3&amp;lt;/code&amp;gt; via the following formulas:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; Y1 = 2 X1 + 5 X2 + X3&lt;br /&gt;
&lt;br /&gt;
Y2 = 3 + 0.5 X1 + 4 X2&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please calculate:&lt;br /&gt;
* covariance matrix X1, X2, X3 (1 pkt)&lt;br /&gt;
* mean values of Y1, Y2 in direct measurement (0.5 pkt)&lt;br /&gt;
* covariance matrix Y1, Y2 (1pkt)&lt;br /&gt;
* uncertainties of quantitites Y1, Y2 (1 pkt)&lt;br /&gt;
* correlation coefficients Y1 and Y2 (0.5 pkt)&lt;br /&gt;
&lt;br /&gt;
== Attention ==&lt;br /&gt;
* Look carefully '''three first slides from lecture 5''' [http://www.if.pw.edu.pl/~lgraczyk/KADD2022/Wyklad5-2022.pdf link]&lt;br /&gt;
* Szczegółowy opis slajdy '''12-16 from lecture 4''' [http://www.if.pw.edu.pl/~lgraczyk/KADD2022/Wyklad4-2022.pdf link]&lt;br /&gt;
* Read data from file (the same as in C++):&lt;br /&gt;
 ifstream ifile;&lt;br /&gt;
 ifile.open(&amp;quot;dane.dat&amp;quot;);&lt;br /&gt;
 double val;&lt;br /&gt;
 while(ifile&amp;gt;&amp;gt;val)&lt;br /&gt;
 {&lt;br /&gt;
   cout&amp;lt;&amp;lt;val&amp;lt;&amp;lt;endl;&lt;br /&gt;
 }&lt;br /&gt;
 ifile.close();&lt;br /&gt;
&lt;br /&gt;
* For all matrix operation (creating matrices of covariance, multiplication of matrices, transposing matrices) - use the class '''&amp;lt;code&amp;gt;TMatrixD&amp;lt;/code&amp;gt;''' [https://root.cern.ch/root/html534/TMatrixT_double_.html link]&lt;br /&gt;
* '''Remember, that matrix operations require correct order of matrices.'''&lt;br /&gt;
* Uncertainty and correlation coefficient of X we obtain from TH2D histograms after reading the data; uncertainties and correlation coefficient of Y we obtain after calculating the matrix of coviarance of Y&lt;br /&gt;
* '''Limits of the histogram ranges in T2DH histograms in my solution are as follows:&lt;br /&gt;
&lt;br /&gt;
  double x1min = 1.5, x1max = 5.0;&lt;br /&gt;
  double x2min = 0.0, x2max = 3.0;&lt;br /&gt;
  double x3min = 4.0, x3max = 16.0;&lt;br /&gt;
  TH2D *h12 = new TH2D(&amp;quot;h12&amp;quot;,&amp;quot;Hist12&amp;quot;,100,x1min,x1max,100,x2min,x2max);&lt;br /&gt;
  TH2D *h13 = new TH2D(&amp;quot;h13&amp;quot;,&amp;quot;Hist13&amp;quot;,100,x1min,x1max,100,x3min,x3max);&lt;br /&gt;
  TH2D *h23 = new TH2D(&amp;quot;h13&amp;quot;,&amp;quot;Hist23&amp;quot;,100,x2min,x2max,100,x3min,x3max);&lt;br /&gt;
&lt;br /&gt;
* [http://pl.wikibooks.org/wiki/Statystyka_matematyczna/Momenty_statystyczne_w_dzia%C5%82aniu Wikibooks]&lt;br /&gt;
&lt;br /&gt;
== Results ==&lt;br /&gt;
Plots:&lt;br /&gt;
[[File:Lab05_KADD2012.png]]&lt;br /&gt;
&lt;br /&gt;
Output:&lt;br /&gt;
 X1=3.00691, u(X1)=0.495242&lt;br /&gt;
 X2=2.00581, u(X1)=0.40909&lt;br /&gt;
 X3=9.97287, u(X3)=1.98102&lt;br /&gt;
 rho(X1,X2)=0.156132&lt;br /&gt;
 rho(X1,X3)=-0.00698853&lt;br /&gt;
 rho(X2,X3)=0.00875851&lt;br /&gt;
 &lt;br /&gt;
 after rounding to 2 significant digits:&lt;br /&gt;
 X1=3.01, u(X1)=0.50&lt;br /&gt;
 X2=2.01, u(X1)=0.41&lt;br /&gt;
 X3=9.97, u(X3)=1.98&lt;br /&gt;
  &lt;br /&gt;
 This is the matrix of covariance for X&lt;br /&gt;
 3x3 matrix is as follows&lt;br /&gt;
 &lt;br /&gt;
      |      0    |      1    |      2    |&lt;br /&gt;
 --------------------------------------------&lt;br /&gt;
    0 |     0.2453      0.0316   -0.006855 &lt;br /&gt;
    1 |     0.0316      0.1674      0.0071 &lt;br /&gt;
    2 |  -0.006855      0.0071       3.924 &lt;br /&gt;
  &lt;br /&gt;
 This is the matrix of covariance for Y&lt;br /&gt;
 2x2 matrix is as follows&lt;br /&gt;
 &lt;br /&gt;
      |      0    |      1    |&lt;br /&gt;
 -------------------------------&lt;br /&gt;
    0 |      9.765       3.949 &lt;br /&gt;
    1 |      3.949       2.865 &lt;br /&gt;
 &lt;br /&gt;
 Y1=26.0157, u(Y1)=3.1249&lt;br /&gt;
 Y2=12.5267, u(Y2)=1.6927404&lt;br /&gt;
 rho(Y1,Y2)=0.746574&lt;br /&gt;
 rho(Y2,Y1)=0.746574&lt;br /&gt;
 &lt;br /&gt;
 after rounding to 2 significant digits:&lt;br /&gt;
 Y1=26.02, u(Y1)=3.13&lt;br /&gt;
 Y2=12.53, u(Y2)=1.70&lt;/div&gt;</summary>
		<author><name>Lgraczyk</name></author>	</entry>

	</feed>