<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>43.1.2.5 Regression line</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p class="HELM_exercise">Exercise</p>
<ol class="HELM_parts">
A different warehouse manager of a company dealing in large quantities of steel cable needs to be able to estimate how much cable is left on his partially used drums. A random sample of twelve partially used drums is taken and each drum is weighed and the corresponding length of cable measured. The results are given in the table below:<p></p><table border="1"><caption>&nbsp;</caption><thead><tr><th scope="col">Weight of drum and cable \( (x) \) kg</th><th scope="col">Measured length of cable \( (y) \) m</th></tr></thead><tbody><tr><td style="text-align: center;">{@x1@}</td><td style="text-align: center;">{@y1@}</td></tr><tr><td style="text-align: center;">{@x2@}</td><td style="text-align: center;">{@y2@}</td></tr><tr><td style="text-align: center;">{@x3@}</td><td style="text-align: center;">{@y3@}</td></tr><tr><td style="text-align: center;">{@x4@}</td><td style="text-align: center;">{@y4@}</td></tr><tr><td style="text-align: center;">{@x5@}</td><td style="text-align: center;">{@y5@}</td></tr><tr><td style="text-align: center;">{@x6@}</td><td style="text-align: center;">{@y6@}</td></tr><tr><td style="text-align: center;">{@x7@}</td><td style="text-align: center;">{@y7@}</td></tr><tr><td style="text-align: center;">{@x8@}</td><td style="text-align: center;">{@y8@}</td></tr><tr><td style="text-align: center;">{@x9@}</td><td style="text-align: center;">{@y9@}</td></tr><tr><td style="text-align: center;">{@x10@}</td><td style="text-align: center;">{@y10@}</td></tr><tr><td style="text-align: center;">{@x11@}</td><td style="text-align: center;">{@y11@}</td></tr><tr><td style="text-align: center;">{@x12@}</td><td style="text-align: center;">{@y12@}</td></tr></tbody></table></ol><ol class="HELM_parts"><p><br></p>

<li><p>Find the least squares regression line in the form \(y = mx+c \). Give your answers to 3 decimal places.</p>

<p> \( y = \) [[input:ans1]] \(x\) +  [[input:ans2]]</p></li>
[[validation:ans1]] [[feedback:prt1]]  [[validation:ans2]] [[feedback:prt2]]

<p><br></p></ol>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p><p>Calculations give \(\sum x = {@sumX@} \), \( \sum x^2 = {@sumX2@}\), \( \sum y = {@sumY@}\) and \(\sum xy = {@sumXY@}\), so that the formulae</p><p>\[&nbsp; b = \dfrac{ \dfrac{ \sum xy}{n} - \dfrac{ \sum x}{n}\dfrac{ \sum y}{n} }{ \dfrac{\sum x^2}{n} - \left( \dfrac{\sum x}{n} \right)^2 }, \text{ and } a = \bar{y} - b \bar{x} \] give \(a = {@a@}\) and \(b = {@b@}\).&nbsp;</p><p>Thus the regression line is</p><p>\[ y = {@b@}x&nbsp; {@a@} \]</p><br><br></p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0.1</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2020070100</text>
    </stackversion>
    <questionvariables>
      <text>x1:30;    x5:50;    x9:70;
x2:40;    x6:50;   x10:80;
x3:40;    x7:60;   x11:80;
x4:50;    x8:70;    x12:80;

y1:70+rand(4);    y5:130+rand(4);    y9:200-rand(4);
y2:90+rand(4);    y6:150;   y10:200
y3:100-rand(4);    y7:160+rand(4);  y11:220-rand(4);
y4:120-rand(4);    y8:190;    y12:230+rand(4);

n:12;

sumX:x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11+x12;
sumX2:x1^2+x2^2+x3^2+x4^2+x5^2+x6^2+x7^2+x8^2+x9^2+x10^2+x11^2+x12^2;
sumXY:x1*y1 + x2*y2 + x3*y3 + x4*y4 + x5*y5 + x6*y6 + x7*y7 + x8*y8 + x9*y9 + x10*y10 + x11*y11 + x12*y12;
sumY:y1+y2+y3+y4+y5+y6+y7+y8+y9+y10+y11+y12;

b:decimalplaces((sumXY/n - sumX/n*sumY/n)/(sumX2/n - (sumX/n)^2),3);
a:decimalplaces(1/n*(sumY - b*sumX),3);
ta1:b;
ta2:a;</text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>{@ta1@}, {@ta2@}</text>
    </questionnote>
    <questiondescription format="moodle_auto_format">
      <text/>
    </questiondescription>
    <questionsimplify>1</questionsimplify>
    <assumepositive>0</assumepositive>
    <assumereal>0</assumereal>
    <prtcorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:green;"><i class="fa fa-check"></i></span> Correct answer, well done.]]></text>
    </prtcorrect>
    <prtpartiallycorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:orange;"><i class="fa fa-adjust"></i></span> Your answer is partially correct.]]></text>
    </prtpartiallycorrect>
    <prtincorrect format="html">
      <text><![CDATA[<span style="font-size: 1.5em; color:red;"><i class="fa fa-times"></i></span> Incorrect answer.]]></text>
    </prtincorrect>
    <decimals>.</decimals>
    <scientificnotation>*10</scientificnotation>
    <multiplicationsign>dot</multiplicationsign>
    <sqrtsign>1</sqrtsign>
    <complexno>i</complexno>
    <inversetrig>cos-1</inversetrig>
    <logicsymbol>lang</logicsymbol>
    <matrixparens>[</matrixparens>
    <isbroken>0</isbroken>
    <variantsselectionseed/>
    <input>
      <name>ans1</name>
      <type>numerical</type>
      <tans>ta1</tans>
      <boxsize>5</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options>mindp:3, maxdp:3</options>
    </input>
    <input>
      <name>ans2</name>
      <type>numerical</type>
      <tans>ta2</tans>
      <boxsize>5</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint/>
      <syntaxattribute>0</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options>mindp:3, maxdp:3</options>
    </input>
    <prt>
      <name>prt1</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans1</sans>
        <tans>ta1</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt1-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt1-1-F</falseanswernote>
        <falsefeedback format="html">
          <text/>
        </falsefeedback>
      </node>
    </prt>
    <prt>
      <name>prt2</name>
      <value>1.0000000</value>
      <autosimplify>1</autosimplify>
      <feedbackstyle>1</feedbackstyle>
      <feedbackvariables>
        <text/>
      </feedbackvariables>
      <node>
        <name>0</name>
        <description/>
        <answertest>AlgEquiv</answertest>
        <sans>ans2</sans>
        <tans>ta2</tans>
        <testoptions/>
        <quiet>0</quiet>
        <truescoremode>=</truescoremode>
        <truescore>1.0000000</truescore>
        <truepenalty/>
        <truenextnode>-1</truenextnode>
        <trueanswernote>prt2-1-T</trueanswernote>
        <truefeedback format="html">
          <text/>
        </truefeedback>
        <falsescoremode>=</falsescoremode>
        <falsescore>0.0000000</falsescore>
        <falsepenalty/>
        <falsenextnode>-1</falsenextnode>
        <falseanswernote>prt2-1-F</falseanswernote>
        <falsefeedback format="html">
          <text><![CDATA[<p></p><p><br></p><p></p>]]></text>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>577156111</deployedseed>
    <deployedseed>177450219</deployedseed>
    <deployedseed>1409882725</deployedseed>
    <deployedseed>1288181778</deployedseed>
    <deployedseed>35402275</deployedseed>
    <deployedseed>962956383</deployedseed>
    <deployedseed>932350213</deployedseed>
    <deployedseed>613017949</deployedseed>
    <deployedseed>1439004040</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta1</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ta2</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt1-1-T</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>1.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-1-T</expectedanswernote>
      </expected>
    </qtest>
    <qtest>
      <testcase>2</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta1+1</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ta2+1</value>
      </testinput>
      <expected>
        <name>prt1</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt1-1-F</expectedanswernote>
      </expected>
      <expected>
        <name>prt2</name>
        <expectedscore>0.0000000</expectedscore>
        <expectedpenalty>0.1000000</expectedpenalty>
        <expectedanswernote>prt2-1-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
