<?xml version="1.0" encoding="UTF-8"?>
<quiz>
  <question type="stack">
    <name>
      <text>37.2.2.1 Dice roll and binomial distribution</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p class="HELM_exercise">Exercise</p><p></p><p>A \({@sides@}\)-faced die is thrown repeatedly {@n_times@} times in all. Find:<br></p><p>\(\text{E}(X)=\) [[input:ans1]] [[validation:ans1]]&nbsp;[[feedback:prt1]]</p><p>\(V(X)= \)&nbsp;[[input:ans2]] [[validation:ans2]]&nbsp;[[feedback:prt2]]<br></p><p>where \(X\) is the random variable for the number of threes obtained.<br></p><p><b>Note:</b> Please write your answer up to 2 decimal places, if required.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text><![CDATA[<p>Consider the occurrence of a three, with <span class="math inline">\(X\)</span> being the number of threes thrown in {@n_times@} trials.</p>
<p>The random variable <span class="math inline">\(X\)</span> follows a binomial distribution. (Why? Refer to the beginning of this section for the criteria if necessary). A trial is the operation of throwing a die. A success is the occurrence of a 3 on a particular trial, so <span class="math inline">\(p={@prob@}\)</span>. We have <span class="math inline">\(X\sim\text{Binomial}(n={@n_times@},\ p={@prob@})\)</span> so that&nbsp;</p><p><span class="math inline">\[\text{E}(X)=np={@n_times@}\times {@prob@}= {@EX@} = {@displaydp(float(ta_1),2)@} ~(\text{to 2 d.p.})\]</span></p><p><span class="math inline">and&nbsp;</span></p><p><span class="math inline">\[\text{V}(X)=npq={@n_times@}\times {@prob@}\times (1-{@prob@})={@VX@}={@displaydp(float(ta_2),2)@} ~ (\text{to 2 d.p.}).\]</span></p>
<p>Hence the standard deviation is <span class="math inline">\(\sigma(X)=\sqrt{{@VX@}} = {@displaydp(float(sqrt(VX)),2)@}\) to 2 d.p.</span></p>
<p><span class="math inline">\(\text{E}(X)={@ta_1@}\)</span> implies that in {@n_times@} throws of a fair {@sides@}-faced die we would expect, on average, to see {@ta_1@} threes. This makes perfect sense, of course.</p>]]></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0</penalty>
    <hidden>0</hidden>
    <idnumber/>
    <stackversion>
      <text>2021072200</text>
    </stackversion>
    <questionvariables>
      <text>sides: rand([4,6,8,10,12,20]);
prob: 1/sides;
n_times: 30+rand(10)
EX: n_times*prob
VX: n_times*prob*(1-prob)
ta_1: decimalplaces(float(EX),2)
ta_2: decimalplaces(float(VX),2)</text>
    </questionvariables>
    <specificfeedback format="html">
      <text/>
    </specificfeedback>
    <questionnote format="moodle_auto_format">
      <text>sides: \({@sides@}\), trials: \({@n_times@}\), \(\text{E}(X) = {@ta_1@}\), \(V(X) = {@ta_2@}\)</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>dispdp(ta_1,2)</tans>
      <boxsize>8</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint>to 2 d.p.</syntaxhint>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options>maxdp:2</options>
    </input>
    <input>
      <name>ans2</name>
      <type>numerical</type>
      <tans>dispdp(ta_2,2)</tans>
      <boxsize>8</boxsize>
      <strictsyntax>1</strictsyntax>
      <insertstars>0</insertstars>
      <syntaxhint>to 2 d.p.</syntaxhint>
      <syntaxattribute>1</syntaxattribute>
      <forbidwords/>
      <allowwords/>
      <forbidfloat>0</forbidfloat>
      <requirelowestterms>0</requirelowestterms>
      <checkanswertype>0</checkanswertype>
      <mustverify>1</mustverify>
      <showvalidation>3</showvalidation>
      <options>maxdp:2</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>NumAbsolute</answertest>
        <sans>ans1</sans>
        <tans>ta_1</tans>
        <testoptions>0.02</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>NumAbsolute</answertest>
        <sans>ans2</sans>
        <tans>ta_2</tans>
        <testoptions>0.02</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/>
        </falsefeedback>
      </node>
    </prt>
    <deployedseed>1143553831</deployedseed>
    <deployedseed>790207532</deployedseed>
    <deployedseed>402897837</deployedseed>
    <deployedseed>268115996</deployedseed>
    <deployedseed>1236467960</deployedseed>
    <deployedseed>1314142580</deployedseed>
    <deployedseed>2029414688</deployedseed>
    <deployedseed>367100173</deployedseed>
    <deployedseed>657539279</deployedseed>
    <deployedseed>473891765</deployedseed>
    <qtest>
      <testcase>1</testcase>
      <description/>
      <testinput>
        <name>ans1</name>
        <value>ta_1</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>ta_2</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>ta_1</value>
      </testinput>
      <testinput>
        <name>ans2</name>
        <value>100</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>0.0000000</expectedscore>
        <expectedpenalty>0.0000000</expectedpenalty>
        <expectedanswernote>prt2-1-F</expectedanswernote>
      </expected>
    </qtest>
  </question>
</quiz>
