// Numbas version: finer_feedback_settings {"name": "Probability - sum of two numbers drawn without replacement", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Probability - sum of two numbers drawn without replacement", "metadata": {"notes": "
7/07/2012:
\nAdded tags.
\nReminded user to input answer as a fraction.
\nChecked calculation.
\n22/07/2012:
\nAdded description.
\nChecked stats extension box.
\n31/07/2012:
\nQuestion appears to be working correctly.
\n20/12/2012:
\nChecked calculation, OK. Added tested1 tag.
", "licence": "Creative Commons Attribution 4.0 International", "description": "\n \t\tTwo numbers are drawn at random without replacement from the numbers m to n.
\n \t\tFind the probability that both are odd given their sum is even.
\n \t\t"}, "showQuestionGroupNames": false, "type": "question", "statement": "\nTwo numbers are drawn at random (and without replacement) from the numbers $\\var{mi}$ to $\\var{ma}$.
\nFind the probability that both numbers are {parity} given that their sum is even.
\n ", "variable_groups": [], "preamble": {"css": "", "js": ""}, "variables": {"numotherpar": {"templateType": "anything", "name": "numotherpar", "group": "Ungrouped variables", "description": "", "definition": "if(parity='even',noodd,noeven)"}, "mi": {"templateType": "anything", "name": "mi", "group": "Ungrouped variables", "description": "", "definition": "random(1..10)"}, "botheven": {"templateType": "anything", "name": "botheven", "group": "Ungrouped variables", "description": "", "definition": "comb(noeven,2)"}, "ma": {"templateType": "anything", "name": "ma", "group": "Ungrouped variables", "description": "", "definition": "mi+random(8..12#2)"}, "parity": {"templateType": "anything", "name": "parity", "group": "Ungrouped variables", "description": "", "definition": "random('odd','even')"}, "mess": {"templateType": "anything", "name": "mess", "group": "Ungrouped variables", "description": "", "definition": "if(gcd(comb(numpar,2),together)=1,'','(after reducing to lowest form as a fraction).')"}, "di": {"templateType": "anything", "name": "di", "group": "Ungrouped variables", "description": "", "definition": "ma-mi"}, "otherparity": {"templateType": "anything", "name": "otherparity", "group": "Ungrouped variables", "description": "", "definition": "if(parity='even','odd','even')"}, "bothodd": {"templateType": "anything", "name": "bothodd", "group": "Ungrouped variables", "description": "", "definition": "comb(noodd,2)"}, "noodd": {"templateType": "anything", "name": "noodd", "group": "Ungrouped variables", "description": "", "definition": "if(isint(mi/2),di/2,di/2+1)"}, "bothsame": {"templateType": "anything", "name": "bothsame", "group": "Ungrouped variables", "description": "", "definition": "if(parity='odd',bothodd,botheven)"}, "noeven": {"templateType": "anything", "name": "noeven", "group": "Ungrouped variables", "description": "", "definition": "if(isint(mi/2),di/2+1,di/2)"}, "numpar": {"templateType": "anything", "name": "numpar", "group": "Ungrouped variables", "description": "", "definition": "if(parity='even',noeven,noodd)"}, "together": {"templateType": "anything", "name": "together", "group": "Ungrouped variables", "description": "", "definition": "botheven+bothodd"}}, "tags": ["MAS1604", "Probability", "checked2015", "conditional probability", "counting", "drawn without replacement", "events", "sampling space", "select without replacement", "sets", "statistics", "subset", "tested1", "urn model", "without replacement"], "parts": [{"prompt": "\nProbability that both numbers are {parity}= [[0]]
\nEnter your answer as a fraction and not a decimal.
\n ", "showCorrectAnswer": true, "type": "gapfill", "gaps": [{"musthave": {"showStrings": false, "strings": ["/"], "partialCredit": 0, "message": "Input your answer as a fraction
"}, "notallowed": {"showStrings": false, "strings": ["."], "partialCredit": 0, "message": "Input your answer as a fraction not a decimal.
"}, "type": "jme", "answer": "{bothsame}/{botheven+bothodd}", "answersimplification": "std", "expectedvariablenames": [], "scripts": {}, "showpreview": true, "vsetrange": [0, 1], "checkvariablenames": false, "checkingaccuracy": 0.001, "showCorrectAnswer": true, "checkingtype": "absdiff", "vsetrangepoints": 5, "marks": 2}], "scripts": {}, "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "ungrouped_variables": ["parity", "otherparity", "ma", "di", "mess", "mi", "numotherpar", "noodd", "together", "bothodd", "botheven", "numpar", "bothsame", "noeven"], "functions": {}, "question_groups": [{"pickQuestions": 0, "name": "", "pickingStrategy": "all-ordered", "questions": []}], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "advice": "\n \n \nAs we are sampling without replacement the best sampling space is the space of all unordered pairs.
\n \n \n \nThis means that when we count up the number of pairs we use the number of ways of selecting pairs.
\n \n \n \nLet $A$ be the event that both numbers are {parity} and $B$ the event that their sum is even.
\n \n \n \nNote that $A$ is a subset of $B$ hence $P(A \\cap B)=P(A)$.
\n \n \n \nThe probability we want to find is $P(A | B)$.
\n \n \n \nUsing the definition of conditional probability:
\n \n \n \n\\[P(A | B) = \\frac{P(A \\cap B)}{P(B)} = \\frac{P(A)}{P(B)} \\]
\n \n \n \nNow there are $\\var{numpar}$ {parity} numbers between $\\var{mi}$ and $\\var{ma}$.
\n \n \n \nand as we are sampling without replacement there are
\n \n \n \n\\[{\\var{numpar} \\choose 2} = \\frac{\\var{numpar}\\times \\var{numpar-1}}{2} = \\var{comb(numpar,2)}\\]
\n \n \n \nsuch pairs, both {parity}.
\n \n \n \nThis gives the number of elements in $A$.
\n \n \n \nAlso since there are $\\var{ma-mi+1-numpar}$ {otherparity} numbers in the range, there are:
\n \n \n \n\\[{\\var{numotherpar} \\choose 2}=\\var{comb(numotherpar,2)}\\] such pairs, both {otherparity}.
\n \n \n \nThere are $\\var{botheven}+\\var{bothodd}=\\var{together}$ pairs with sum even.
\n \n \n \nThis gives the number of events in $B$.
\n \n \n \nHence \\[\\frac{P(A)}{P(B)}=\\frac{\\var{comb(numpar,2)}}{\\var{together}}\\]
\n \n \n \nSo the probability that both are {parity} given their sum is even is
\n \n \n \n\\[\\simplify[std]{{comb(numpar,2)}/{together}}\\]
\n \n \n \n{mess}
\n \n \n ", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}, {"name": "Xiaodan Leng", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/2146/"}]}