(* Content-type: application/mathematica *)

(*** Wolfram Notebook File ***)

(* *)

(* CreatedBy='Mathematica 7.0' *)

(*CacheID: 234*)

(* Internal cache information:

NotebookFileLineBreakTest

NotebookFileLineBreakTest

NotebookDataPosition[ 145, 7]

NotebookDataLength[ 86456, 2197]

NotebookOptionsPosition[ 81582, 2032]

NotebookOutlinePosition[ 82252, 2057]

CellTagsIndexPosition[ 82209, 2054]

WindowFrame->Normal*)

(* Beginning of Notebook Content *)

Notebook[{

Cell[TextData[{

StyleBox["Calibration: linear relationship, normal distribution.",

FontSize->14,

FontWeight->"Bold",

FontVariations->{"Underline"->True},

FontColor->RGBColor[0, 0, 1]],

StyleBox["\n\nSituation:\n\nThere is a linear relationship between a \

dependent variable y and an independent variable x:\n y = ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Beta]",

FontColor->RGBColor[0, 0, 1]],

StyleBox["0",

FontSize->9,

FontVariations->{"CompatibilityType"->"Subscript"},

FontColor->RGBColor[0, 0, 1]],

StyleBox[" + ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Beta]",

FontColor->RGBColor[0, 0, 1]],

StyleBox["1",

FontSize->9,

FontVariations->{"CompatibilityType"->"Subscript"},

FontColor->RGBColor[0, 0, 1]],

StyleBox[" ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["x + ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Epsilon]",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\nThe variable x is assumed to be exactly known. The experimental \

error ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Epsilon]",

FontColor->RGBColor[0, 0, 1]],

StyleBox[" is a random variable with a normal distribution, an expectation \

value of zero, and a standard deviation of ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Sigma]",

FontColor->RGBColor[0, 0, 1]],

StyleBox[":\n ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Epsilon]",

FontColor->RGBColor[0, 0, 1]],

StyleBox[" ~ N(0,",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Sigma]",

FontColor->RGBColor[0, 0, 1]],

StyleBox[")\nThe parameters ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Beta]",

FontColor->RGBColor[0, 0, 1]],

StyleBox["0",

FontSize->9,

FontVariations->{"CompatibilityType"->"Subscript"},

FontColor->RGBColor[0, 0, 1]],

StyleBox[", ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Beta]",

FontColor->RGBColor[0, 0, 1]],

StyleBox["1",

FontSize->9,

FontVariations->{"CompatibilityType"->"Subscript"},

FontColor->RGBColor[0, 0, 1]],

StyleBox[" and ",

FontColor->RGBColor[0, 0, 1]],

StyleBox["\[Sigma]",

FontColor->RGBColor[0, 0, 1]],

StyleBox[" are unknown. Estimates b",

FontColor->RGBColor[0, 0, 1]],

StyleBox["0",

FontSize->9,

FontVariations->{"CompatibilityType"->"Subscript"},

FontColor->RGBColor[0, 0, 1]],

StyleBox[", b",

FontColor->RGBColor[0, 0, 1]],

StyleBox["1",

FontSize->9,

FontVariations->{"CompatibilityType"->"Subscript"},

FontColor->RGBColor[0, 0, 1]],

StyleBox[" and s are to be determined by a calibration. The values of y are \

measured for various choices of x. Subsequently the calibration is to be \

applied to measurements of y with the corresponding values of x unknown, \

leading to confidence intervals for these x-values.\n\nThis model is also \

known as (first kind) Linear Regression.\n\

______\

\n\nNote: - All names for variables and constants must be spelled with the \

proper\n case. Therefore \"True\" is different from \"true\". The \

latter\n specification will lead to an error.\n - Use the period \

\".\" as a decimal point, not the comma \",\".\n - None of the variables \

specified in the declarative part of this\n notebook is modified in \

any way by evaluating the computational part.\n\

______\

",

FontColor->RGBColor[0, 0, 1]]

}], "Text",

Editable->False,

CellHorizontalScrolling->True,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier"],

Cell[CellGroupData[{

Cell[TextData[{

"Important: The statements\n Needs[\"Statistics`HypothesisTesting`\"];\n\

have to be evaluated only once in a ",

StyleBox["Mathematica",

FontSlant->"Italic"],

" session, though they can be evaluated as many times as desired. However, \

they ",

StyleBox["must",

FontVariations->{"Underline"->True}],

" be evaluated ",

StyleBox["before",

FontVariations->{"Underline"->True}],

" any calculation in this notebook is performed. Failing to do so will cause \

multiple declarations of some hidden variables, which renders your ",

StyleBox["Mathematica",

FontSlant->"Italic"],

" session useless. Quit and re-launch ",

StyleBox["Mathematica",

FontSlant->"Italic"],

" in the case of diagnostic messages when evaluating the following \

statements."

}], "Text",

Evaluatable->False,

CellChangeTimes->{{3.489233930625552*^9, 3.489233934471589*^9}},

AspectRatioFixed->True,

FontFamily->"Courier",

FontColor->RGBColor[0, 0, 1]],

Cell[BoxData[

RowBox[{

RowBox[{"Needs", "[", "\"\<HypothesisTesting`\>\"", "]"}], ";"}]], "Input",

CellChangeTimes->{3.489164182070148*^9},

AspectRatioFixed->True]

}, Open ]],

Cell[CellGroupData[{

Cell[TextData[{

StyleBox["Specification of the standard deviation",

FontVariations->{"Underline"->True}],

"\n\nNormally the standard deviation is estimated from the actual sample \

data. Sometimes a (presumably better) estimate is available from an external \

source. Sometimes the exact value of the standard deviation is known.\n\

Specify whether the standard deviation is known from an external source. \

Choose one of the two statements:\n StandardDeviationExternal = True;\n \

StandardDeviationExternal = False;\nIf you declare the standard deviation \

as external, specify its value by the statement:\n StdDev = 1.38;\n\

Specify the associated number of degrees of freedom as in the following \

example:\n NumberOfDegreesOfFreedom = 5;\nIf the standard deviation is \

exactly known, specify the value Infinity:\n NumberOfDegreesOfFreedom = \

Infinity;\nThe values for the standard deviation and its number of degrees of \

freedom are ignored if the standard deviation is to be estimated from the \

sample data. Note, however, that the statements, if left in this notebook, \

must have the proper syntax, as they are evaluated."

}], "Text",

Editable->False,

CellHorizontalScrolling->True,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[0, 0, 1]],

Cell["\<\

StandardDeviationExternal = False;

StdDev = 1.38;

NumberOfDegreesOfFreedom = Infinity;\

\>", "Input",

ImageRegion->{{0, 1}, {0, 1}}]

}, Open ]],

Cell[CellGroupData[{

Cell[TextData[{

StyleBox["Specification of the confidence coefficient",

FontVariations->{"Underline"->True}],

"\n\nThe confidence coefficient 1-",

"\[Alpha]",

" is the probability associated with the confidence intervals to be \

calculated. The confidence coefficient must be a value between 0 and 1, \

excluding limits. A typical value is 0.95 leading to the so-called 95% \

confidence intervals.\nSpecify the confidence coefficient as in the following \

example:\n ConfidenceCoefficient = 0.95;"

}], "Text",

Editable->False,

CellHorizontalScrolling->True,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[0, 0, 1]],

Cell["ConfidenceCoefficient = 0.95;", "Input",

ImageRegion->{{0, 1}, {0, 1}}]

}, Open ]],

Cell[CellGroupData[{

Cell[TextData[{

StyleBox["Specification of the calibration data",

FontVariations->{"Underline"->True}],

"\n\nSpecify the values for x and y, in this sequence, as in the following \

example:\n CalibrationData = { { 4.184 , 1.703 } ,\n \

{ 3.15 , 1.53*10^2 } ,\n { 1.63 , \

0.38*10^-3 } };\nMake sure the punctuation is correct. CalibrationData is a \

list of lists. The elements of a list are separated by commas. The delimiters \

of a list are braces {}. Blanks and carriage returns are ignored. Their use \

is strongly encouraged for the sake of legibility."

}], "Text",

Editable->False,

CellHorizontalScrolling->True,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[0, 0, 1]],

Cell["\<\

CalibrationData = { { 0 , 0 } ,

{ 0.04855 , 38.21 } , { 0.04855 , 25.37 } , { 0.04855 , \

41.57} ,

{ 0.0971 , 54.55 } , { 0.0971 , 56.18 } , { 0.0971 , \

54.81 } ,

{ 0.1942 , 92.47 } , { 0.1942 , 100.46 } , { 0.1942 , \

95.05 } ,

{ 0.2913 , 142.03 } , { 0.2913 , 128.24 } , { 0.2913 , \

141.05 } ,

{ 0.3884 , 144.21 } , { 0.3884 , 137.18 } , { 0.3884 , \

132.24 } ,

{ 0.494 , 181.00 } , { 0.494 , 171.97 } , { 0.494 , \

173.73 } };\

\>", "Input",

ImageRegion->{{0, 1}, {0, 1}}]

}, Open ]],

Cell[CellGroupData[{

Cell[TextData[{

"All results calculated in this notebook can be written into a disk file. \

The document to be created will be a ",

StyleBox["Mathematica",

FontSlant->"Italic"],

" notebook. However, it can be opened from within Microsoft Word as a \"text \

only\" file. The text can be transferred into a Word document by means of \

copying and pasting. The items in the document are separated by tab \

characters, which makes formatting straightforward within Word.\nEach time an \

input cell that writes to the file is evaluated, the text is appended to the \

end of the file. Evaluating a cell twice means a double entry in the file. If \

the results should not be written into a file, the corresponding input cells \

can be left unevaluated.\nEnter the name of the document as in the following \

example:\n FolderName = \"Harddisk:GC:\"\n ResultFileName = \"Fatty \

acids\";\nThis would create a file named \"Fatty acids\" on the device named \

\"Harddisk\" in folder \"GC\". Note that all folder names must be terminated \

by a colon \":\". The folders must already exist. They will not be created by \

",

StyleBox["Mathematica",

FontSlant->"Italic"],

".\nIf the file already exists, its contents are not to be changed in any \

way, unless the variable \"OverwriteFile\" is set \"True\" as in the \

following example:\n OverwriteFile = True;\nThis is a rather dangerous \

specification since ",

StyleBox["Mathematica",

FontSlant->"Italic"],

" will destroy the file without warning. If you don't explicitly want to \

overwrite a file, leave the statement as\n OverwriteFile = False;\nin the \

notebook, protecting your results from unintended deletion."

}], "Text",

Editable->False,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[1, 0, 1]],

Cell["\<\

FolderName = \"C:\\\\LabSolutions\\\\Data\\\\Lab Course\\\\M2\\\\\";

ResultFileName = \"11_Trinkwasser_Cu\";

OverwriteFile = True;\

\>", "Input",

CellChangeTimes->{{3.507880919015625*^9, 3.507880919375*^9}, {

3.50788095128125*^9, 3.507880966234375*^9}, {3.507881073234375*^9,

3.507881107765625*^9}, {3.601987966543277*^9, 3.6019880030629406`*^9}},

ImageRegion->{{0, 1}, {0, 1}}]

}, Open ]],

Cell[CellGroupData[{

Cell["\<\

Evaluate this cell to open the output file for writing. Only a single file \

can be open at any one time.\

\>", "Text",

Editable->False,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[1, 0, 1]],

Cell[CellGroupData[{

Cell["\<\

Module[{},

Bad = Head[OutputFileIsOpen]==Integer;

If[ Bad , Print[\"Error: There is already a file open: \",OutputFileName] ];

If[ Bad , Abort[] ];

Bad = True;

If[ Head[FolderName]==String , Bad=False ];

If[ Bad , Print[\"Error: No folder and file names have been specified.\"] ];

If[ Bad , Abort[] ];

FileList = FileNames[ ResultFileName , FolderName ];

Bad = Length[FileList]>1;

If[ Bad , Print[\"Error: Illegal file specification.\"] ];

If[ Bad , Abort[] ];

Bad = Length[FileList]==1 & Not[OverwriteFile];

If[ Bad , Print[\"Error: The file specified already exists.\"] ];

If[ Bad , Print[\" Set variable OverwriteFile to True and \

re-evaluate.\"] ];

If[ Bad , Abort[] ];

Status = OpenWrite[ StringJoin[FolderName,ResultFileName] ,

FormatType->OutputForm ];

Bad = True;

If[ Head[Status]==OutputStream , Bad=False ];

If[ Bad , Print[\"Error: The file could not be opened.\"] ];

If[ Bad , Abort[] ];

OutputFileIsOpen = 1;

If[ Length[FileList]==0 ,

FileList=FileNames[ResultFileName,FolderName] ];

OutputFileName=FileList[[1]];

StreamName = Status;

Print[ \"File has been opened and is ready for writing.\" ];

Print[ OutputFileName ];

];\

\>", "Input",

Editable->False,

CellOpen->False,

ImageRegion->{{0, 1}, {0, 1}}],

Cell[BoxData["\<\"File has been opened and is ready for writing.\"\>"], \

"Print",

CellChangeTimes->{3.507918799390625*^9, 3.6019879319736156`*^9,

3.601988016260564*^9, 3.601988057241836*^9}],

Cell[BoxData["\<\"C:\\\\LabSolutions\\\\Data\\\\Lab \

Course\\\\M2\\\\11_Trinkwasser_Cu\"\>"], "Print",

CellChangeTimes->{3.507918799390625*^9, 3.6019879319736156`*^9,

3.601988016260564*^9, 3.601988057241836*^9}]

}, Open ]]

}, Open ]],

Cell[CellGroupData[{

Cell["\<\

Evaluate this cell to perform the calculation of the calibration part.\

\>", "Text",

Editable->False,

CellHorizontalScrolling->True,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[0, 0, 1]],

Cell[CellGroupData[{

Cell["\<\

CalibrationDone = False;

Off[General::spell1,General::spell];

CalculationAborted = False;

CheckAbort[ Module[ {} ,

NumberOfDigits = 50;

Print[ \"Calibration: Linear relationship, normal distribution.\"];

Print[ \" \" ];

Bad = StandardDeviationExternal != True &

StandardDeviationExternal != False;

If[ Bad ,

Print[ \"Illegal value for StandardDeviationExternal: \" ,

StandardDeviationExternal ] ];

If[ Bad , Abort[] ];

If[ StandardDeviationExternal ,

Module[{},

Bad = True;

If[Positive[StdDev],Bad=False];

If[Bad,Print[\"Illegal value for StdDev: \",

StdDev]];

If[Bad,Abort[]];

Print[\"Standard deviation from external source = \",

StdDev]];

Bad = True;

If[Positive[NumberOfDegreesOfFreedom],Bad=False];

If[Bad,Print[\"Illegal value for NumberOfDegreesOfFreedom: \",

NumberOfDegreesOfFreedom]];

If[Bad,Abort[]];

If[NumberOfDegreesOfFreedom==Infinity,

Print[\"(exactly known)\"],

Print[\"Associated number of degrees of freedom = \" ,

NumberOfDegreesOfFreedom]

],

Print[\"The standard deviation will be estimated from the sample data.\"] \

];

Bad = ConfidenceCoefficient >= 1 ||

ConfidenceCoefficient <= 0;

If[ Bad ,

Print[ \"Illegal value for ConfidenceCoefficient: \" ,

ConfidenceCoefficient ] ];

If[ Bad , Abort[] ];

RationalConfidenceCoefficient = Rationalize[100*ConfidenceCoefficient,0];

If[ Denominator[RationalConfidenceCoefficient] == 1 ,

Print[ \"Confidence coefficient = \" ,

RationalConfidenceCoefficient,\"%\" ] ,

Print[ \"Confidence coefficient = \" ,

100*ConfidenceCoefficient,\"%\" ] ];

Print[ \" \" ];

Print[\"Results of calibration:\"];

Print[\" \"];

SampleSize = Length[CalibrationData];

Do[ Module[{xx,yy},

Bad=True;

xx=CalibrationData[[i,1]];

If[xx<0||xx>=0,Bad=False];

If[Bad,Print[\"Illegal x value in data pair \",i,\": \",xx]];

If[Bad,Print[\"Edit and re-evaluate the definition of CalibrationData.\"]];

If[Bad,Abort[]];

Bad=True;

yy=CalibrationData[[i,2]];

If[yy<0||yy>=0,Bad=False];

If[Bad,Print[\"Illegal y value in data pair \",i,\": \",yy]];

If[Bad,Print[\"Edit and re-evaluate the definition of CalibrationData.\"]];

If[Bad,Abort[]]

] , {i,SampleSize} ];

x = Table[N[Rationalize[CalibrationData[[i,1]],0],NumberOfDigits],{i,\

SampleSize}];

y = Table[N[Rationalize[CalibrationData[[i,2]],0],NumberOfDigits],{i,\

SampleSize}];

XMatrix = Table[ {1,x[[i]]} , {i,SampleSize} ];

XTX1 = Inverse[Transpose[XMatrix].XMatrix];

{b0,b1} = XTX1 . (Transpose[XMatrix].y);

yEstimated = XMatrix . {b0,b1};

residuals = y - yEstimated;

leverages = Table[Null,{SampleSize}];

normalizedResiduals = Table[Null,{SampleSize}];

Do[x0 = {{1},{x[[i]]}};

leverages[[i]] = 1/Sqrt[1-(Transpose[x0].XTX1.x0)[[1,1]]];

normalizedResiduals[[i]] = residuals[[i]] * leverages[[i]],

{i,SampleSize}];

If[ StandardDeviationExternal ,

s = StdDev ,

s = Sqrt[(residuals.residuals)/(SampleSize-2)] ];

If[ StandardDeviationExternal ,

nu = NumberOfDegreesOfFreedom ,

nu = SampleSize-2 ];

t95 = If[ nu==Infinity ,

NormalCI[0,1,ConfidenceLevel->ConfidenceCoefficient][[2]] ,

StudentTCI[0,1,nu,ConfidenceLevel->ConfidenceCoefficient][[2]] ];

sb0 = s * Sqrt[XTX1[[1,1]]];

sb0t = t95 * sb0;

sb1 = s * Sqrt[XTX1[[2,2]]];

sb1t = t95 * sb1;

Bad = True;

If[ Head[yList]==List , Bad=False\[NonBreakingSpace]];

If[ Bad , yList={} ];

Clear[yEst,CIyMeanUpper,CIyMeanLower,CIySingleUpper,CIySingleLower];

yEst[xx_] := Evaluate[b0+b1*xx];

CIyMeanUpper[xx_] := Evaluate[b0+b1*xx+t95*s*Sqrt[{{1,xx}}.XTX1.{{1},{xx}}]];

CIyMeanLower[xx_] := Evaluate[b0+b1*xx-t95*s*Sqrt[{{1,xx}}.XTX1.{{1},{xx}}]];

CIySingleUpper[xx_] := \

Evaluate[b0+b1*xx+t95*s*Sqrt[1+{{1,xx}}.XTX1.{{1},{xx}}]];

CIySingleLower[xx_] := \

Evaluate[b0+b1*xx-t95*s*Sqrt[1+{{1,xx}}.XTX1.{{1},{xx}}]];

CalibrationDone = True;

Print[\"Standard deviation of experimental errors = \" , N[s,7] ];

Print[\" \"];

Print[\"Slope: \",N[b1,7],\" \[PlusMinus] \",N[sb1t,7]];

Print[\" upper limit: \",N[b1+sb1t,7]];

Print[\" mean: \",N[b1,7]];

Print[\" lower limit: \",N[b1-sb1t,7]];

Print[\" standard deviation: \",N[sb1,7]];

Print[\" \"];

Print[\"Intercept: \",N[b0,7],\" \[PlusMinus] \",N[sb0t,7]];

Print[\" upper limit: \",N[b0+sb0t,7]];

Print[\" mean: \",N[b0,7]];

Print[\" lower limit: \",N[b0-sb0t,7]];

Print[\" standard deviation: \",N[sb0,7]];

Print[\" \"];

Print[TableForm[Table[{N[x[[i]],7],N[y[[i]],7],N[yEstimated[[i]],7]

,N[residuals[[i]]],N[leverages[[i]]]},{i,SampleSize}],

TableHeadings->{None,{\"x\",\"y measured\",\"y \

estimated\",\"residual\",\"leverage\"}},

TableAlignments->Center,TableSpacing->{0,3}]];

] , CalculationAborted=True; ]

On[General::spell1,General::spell];

If[ CalculationAborted , Abort[] ];\

\>", "Input",

Editable->False,

CellOpen->False,

ImageRegion->{{0, 1}, {0, 1}}],

Cell[BoxData["\<\"Calibration: Linear relationship, normal \

distribution.\"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713130608`*^9}],

Cell[BoxData["\<\" \"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071328661*^9}],

Cell[BoxData["\<\"The standard deviation will be estimated from the sample \

data.\"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071328661*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\"Confidence coefficient = \"\>", "\[InvisibleSpace]", "95",

"\[InvisibleSpace]", "\<\"%\"\>"}],

SequenceForm["Confidence coefficient = ", 95, "%"],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071328661*^9}],

Cell[BoxData["\<\" \"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071328661*^9}],

Cell[BoxData["\<\"Results of calibration:\"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071328661*^9}],

Cell[BoxData["\<\" \"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071328661*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\"Standard deviation of experimental errors = \"\>",

"\[InvisibleSpace]", "13.24873299092567095382103306687174066445`7."}],

SequenceForm[

"Standard deviation of experimental errors = ",

13.24873299092567095382103306687174066445`7.],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData["\<\" \"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\"Slope: \"\>", "\[InvisibleSpace]",

"320.79816290459174391208459573642036372238`7.",

"\[InvisibleSpace]", "\<\" \[PlusMinus] \"\>", "\[InvisibleSpace]",

"39.42808239341546`"}],

SequenceForm[

"Slope: ", 320.79816290459174391208459573642036372238`7., " \[PlusMinus] ",

39.42808239341546],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" upper limit: \"\>", "\[InvisibleSpace]",

"360.2262452980072`"}],

SequenceForm[" upper limit: ", 360.2262452980072],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" mean: \"\>", "\[InvisibleSpace]",

"320.79816290459174391208459573642036372238`7."}],

SequenceForm[

" mean: ", 320.79816290459174391208459573642036372238`7.],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" lower limit: \"\>", "\[InvisibleSpace]",

"281.37008051117624`"}],

SequenceForm[" lower limit: ", 281.37008051117624`],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" standard deviation: \"\>", "\[InvisibleSpace]",

"18.68792837045327604782050409380218140661`7."}],

SequenceForm[

" standard deviation: ", 18.68792837045327604782050409380218140661`7.],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData["\<\" \"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\"Intercept: \"\>", "\[InvisibleSpace]",

"23.87830640038239463187332001944330923495`7.",

"\[InvisibleSpace]", "\<\" \[PlusMinus] \"\>", "\[InvisibleSpace]",

"11.397721196298905`"}],

SequenceForm[

"Intercept: ", 23.87830640038239463187332001944330923495`7.,

" \[PlusMinus] ", 11.397721196298905`],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" upper limit: \"\>", "\[InvisibleSpace]",

"35.2760275966813`"}],

SequenceForm[" upper limit: ", 35.2760275966813],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" mean: \"\>", "\[InvisibleSpace]",

"23.87830640038239463187332001944330923495`7."}],

SequenceForm[

" mean: ", 23.87830640038239463187332001944330923495`7.],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.6019880713442607`*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" lower limit: \"\>", "\[InvisibleSpace]",

"12.480585204083491`"}],

SequenceForm[" lower limit: ", 12.480585204083491`],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071359861*^9}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\" standard deviation: \"\>", "\[InvisibleSpace]",

"5.40223577645770094194191512950453195561`7."}],

SequenceForm[

" standard deviation: ",

5.40223577645770094194191512950453195561`7.],

Editable->False]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071359861*^9}],

Cell[BoxData["\<\" \"\>"], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071359861*^9}],

Cell[BoxData[

TagBox[

TagBox[GridBox[{

{

TagBox["\<\"x\"\>",

HoldForm],

TagBox["\<\"y measured\"\>",

HoldForm],

TagBox["\<\"y estimated\"\>",

HoldForm],

TagBox["\<\"residual\"\>",

HoldForm],

TagBox["\<\"leverage\"\>",

HoldForm]},

{"0", "0", "23.87830640038239463187332001944330923495`7.",

RowBox[{"-", "23.878306400382396`"}], "1.0951805889661104`"},

{"0.04855`7.", "38.21`7.",

"39.45305720940032379880502714244651789367`7.",

RowBox[{"-", "1.2430572094003238`"}], "1.0689131078135643`"},

{"0.04855`7.", "25.37`7.",

"39.45305720940032379880502714244651789367`7.",

RowBox[{"-", "14.083057209400323`"}], "1.0689131078135643`"},

{"0.04855`7.", "41.57`7.",

"39.45305720940032379880502714244651789367`7.", "2.1169427905996763`",

"1.0689131078135643`"},

{"0.0971`7.", "54.55`7.", "55.02780801841825296573673426544972655239`7.",

RowBox[{"-", "0.477808018418253`"}], "1.049834030521615`"},

{"0.0971`7.", "56.18`7.", "55.02780801841825296573673426544972655239`7.",

"1.152191981581747`", "1.049834030521615`"},

{"0.0971`7.", "54.81`7.", "55.02780801841825296573673426544972655239`7.",

RowBox[{"-", "0.21780801841825295`"}], "1.049834030521615`"},

{"0.1942`7.", "92.47`7.", "86.17730963645411129960014851145614386983`7.",

"6.292690363545889`", "1.029572727729699`"},

{"0.1942`7.", "100.46`7.",

"86.17730963645411129960014851145614386983`7.", "14.282690363545889`",

"1.029572727729699`"},

{"0.1942`7.", "95.05`7.", "86.17730963645411129960014851145614386983`7.",

"8.872690363545889`", "1.029572727729699`"},

{"0.2913`7.", "142.03`7.",

"117.32681125448996963346356275746256118727`7.", "24.70318874551003`",

"1.0303682025955927`"},

{"0.2913`7.", "128.24`7.",

"117.32681125448996963346356275746256118727`7.", "10.91318874551003`",

"1.0303682025955927`"},

{"0.2913`7.", "141.05`7.",

"117.32681125448996963346356275746256118727`7.", "23.72318874551003`",

"1.0303682025955927`"},

{"0.3884`7.", "144.21`7.",

"148.47631287252582796732697700346897850472`7.",

RowBox[{"-", "4.266312872525828`"}], "1.0523703683705696`"},

{"0.3884`7.", "137.18`7.",

"148.47631287252582796732697700346897850472`7.",

RowBox[{"-", "11.296312872525828`"}], "1.0523703683705696`"},

{"0.3884`7.", "132.24`7.",

"148.47631287252582796732697700346897850472`7.",

RowBox[{"-", "16.23631287252583`"}], "1.0523703683705696`"},

{"0.494`7.", "181.`7.", "182.3525988752507161244431103132349689138`7.",

RowBox[{"-", "1.352598875250716`"}], "1.1056822648587155`"},

{"0.494`7.", "171.97`7.", "182.3525988752507161244431103132349689138`7.",

RowBox[{"-", "10.382598875250716`"}], "1.1056822648587155`"},

{"0.494`7.", "173.73`7.", "182.3525988752507161244431103132349689138`7.",

RowBox[{"-", "8.622598875250716`"}], "1.1056822648587155`"}

},

GridBoxAlignment->{

"Columns" -> {{Center}}, "ColumnsIndexed" -> {}, "Rows" -> {{Center}},

"RowsIndexed" -> {}},

GridBoxDividers->{

"Columns" -> {{False}}, "ColumnsIndexed" -> {},

"Rows" -> {False, True, {False}, False}, "RowsIndexed" -> {}},

GridBoxSpacings->{"Columns" -> {

Offset[0.27999999999999997`], {

Offset[2.0999999999999996`]},

Offset[0.27999999999999997`]}, "ColumnsIndexed" -> {}, "Rows" -> {

Offset[0.2], {

Offset[0.]},

Offset[0.2]}, "RowsIndexed" -> {}}],

{None, OutputFormsDump`HeadedColumns}],

Function[BoxForm`e$,

TableForm[

BoxForm`e$,

TableHeadings -> {

None, {"x", "y measured", "y estimated", "residual", "leverage"}},

TableAlignments -> Center, TableSpacing -> {0, 3}]]]], "Print",

CellChangeTimes->{3.507900702814855*^9, 3.507918803359375*^9,

3.601988071359861*^9}]

}, Open ]]

}, Open ]],

Cell[CellGroupData[{

Cell["\<\

Evaluate this cell to write the results of the calibration to disk.\

\>", "Text",

Editable->False,

CellHorizontalScrolling->True,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[1, 0, 1]],

Cell["\<\

Module[{},

Bad = True;

If[ Head[CalibrationDone]==Symbol , Bad=False ];

If[ Bad , Print[\"Error: First perform calculation on calibration.\"] ];

If[ Bad , Abort[] ];

Bad = True;

If[ CalibrationDone , Bad=False ];

If[ Bad , Print[\"Error: First perform calculation on calibration.\"] ];

If[ Bad , Abort[] ];

Write[StreamName,\"Calibration: Linear relationship, normal distribution.\"];

Write[StreamName,\" \"];

Write[StreamName,\"Results of calibration:\"];

Write[StreamName,\" \"];

If[ StandardDeviationExternal ,

Module[{},

Write[StreamName,\"Standard deviation from external source = \",StdDev]];

If[NumberOfDegreesOfFreedom==Infinity,

Write[StreamName,\"(exactly known)\"],

Write[StreamName,\"Associated number of degrees of freedom = \" \

,NumberOfDegreesOfFreedom]

],

Write[StreamName,\"The standard deviation will be estimated from the \

sample data.\"] ];

Write[StreamName,\"Standard deviation of experimental errors = \" , N[s,7] ];

Write[StreamName,\"Associated number of degrees of freedom = \",nu];

Write[StreamName,\" \"];

Write[StreamName,\"Slope: \",N[b1,7],\" \[PlusMinus] \",N[sb1t,7]];

Write[StreamName,\"\\tupper limit:\\t\",N[b1+sb1t,7]];

Write[StreamName,\"\\tmean:\\t\",N[b1,7]];

Write[StreamName,\"\\tlower limit:\\t\",N[b1-sb1t,7]];

Write[StreamName,\"\\tstandard deviation:\\t\",N[sb1,7]];

Write[StreamName,\" \"];

Write[StreamName,\"Intercept:\\t\",N[b0,7],\" \[PlusMinus] \",N[sb0t,7]];

Write[StreamName,\"\\tupper limit:\\t\",N[b0+sb0t,7]];

Write[StreamName,\"\\tmean:\\t\",N[b0,7]];

Write[StreamName,\"\\tlower limit:\\t\",N[b0-sb0t,7]];

Write[StreamName,\"\\tstandard deviation:\\t\",N[sb0,7]];

Write[StreamName,\" \"];

Write[StreamName,\"\\tx\\ty measured\\ty estimated\\tresidual\\tleverage\"];

Do[Write[StreamName,\"\\t\",N[x[[i]],7],

\"\\t\",N[y[[i]],7],

\"\\t\",N[yEstimated[[i]],7],

\"\\t\",N[residuals[[i]],7],

\"\\t\",N[leverages[[i]],7]] , {i,SampleSize} ];

Write[StreamName,\" \"];

Write[StreamName,\"End of calibration data.\"];

Write[StreamName,\" \"];

Write[StreamName,\" \"];

];\

\>", "Input",

Editable->False,

CellOpen->False,

ImageRegion->{{0, 1}, {0, 1}}]

}, Open ]],

Cell[CellGroupData[{

Cell["\<\

Evaluate this cell to close the output file. As soon as the file is closed, \

no more output can be appended to the file. Instead a new file must be opened.\

\>", "Text",

Editable->False,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[1, 0, 1]],

Cell[CellGroupData[{

Cell[TextData[{

"Module[{},\nBad = True;\nIf[ Head[OutputFileIsOpen]==Integer , Bad=False ];\

\nIf[ Bad , Print[\"Error: There is no file open.\"] ];\nIf[ Bad , Abort[] ];\

\nStatus = Close[StreamName];\nBad = True;\nIf[ Head[Status]==String , \

Bad=False ];\nIf[ Bad , Print[\"Fatal error: File could not be closed. Quit \

the ",

StyleBox["Mathematica",

FontSlant->"Italic"],

" kernel.\"] ];\nIf[ Bad , Abort[] ];\nRemove[OutputFileIsOpen];\n\

Print[\"File has been closed: \",OutputFileName];\n];"

}], "Input",

Editable->False,

CellOpen->False,

ImageRegion->{{0, 1}, {0, 1}}],

Cell[BoxData[

InterpretationBox[

RowBox[{"\<\"File has been closed: \"\>",

"\[InvisibleSpace]", "\<\"C:\\\\Documents and \

Settings\\\\Praktikum\\\\Desktop\\\\11_Trinkwasser_Cu\"\>"}],

SequenceForm[

"File has been closed: ",

"C:\\Documents and Settings\\Praktikum\\Desktop\\11_Trinkwasser_Cu"],

Editable->False]], "Print",

CellChangeTimes->{3.601988040503007*^9}]

}, Open ]]

}, Open ]],

Cell[CellGroupData[{

Cell["\<\

Evaluate this cell to visualize confidence intervals of the calibration part. \

The output cell shows the axes of a coordinate system, the experimental data \

pairs as black dots, and the estimated model function as a straight line. In \

addition two pairs of confidence intervals around the calibration line are \

shown. The outer curves, drawn in green, are the confidence intervals of a \

single measurement of y, given a particular (exact) value of x. The inner \

curves, drawn in red, correspond to the mean of y, given x.

Specify whether the origin of the coordinate system has to be included in the \

plot. Choose between one of the following statements:

IncludeOrigin = True;

IncludeOrigin = False;\

\>", "Text",

Editable->False,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[0, 0, 1]],

Cell["IncludeOrigin = True;", "Input",

ImageRegion->{{0, 1}, {0, 1}}],

Cell["\<\

The size of the plot can be altered by first clicking on the plot and then \

dragging a corner of the picture. The plot can be copied to the clipboard by \

clicking on the plot and using the Copy function. It can then be pasted into \

a Word document.\

\>", "Text",

Editable->False,

ImageRegion->{{0, 1}, {0, 1}},

FontFamily->"Courier",

FontColor->RGBColor[0, 0, 1]],