// Numbas version: finer_feedback_settings {"name": "XProbability mass function of string of heads from weighted coin,", "extensions": [], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"metadata": {"notes": "

04/02/2013:

\n

First draft finished.

", "description": "

A weighted coin with given $P(H),\\;P(T)$ is tossed 3 times. Let $X$ be the random variable which denotes the longest string of consecutive heads that occur during these tosses. Find the Probability Mass Function (PMF), expectation and variance of $X$.

", "licence": "Creative Commons Attribution 4.0 International"}, "type": "question", "preamble": {"css": "", "js": ""}, "advice": "

a)

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
EventHHHHHTHTHHTT
Probability$\\var{h}^3=\\var{h^3}$$\\var{h}^2\\times\\var{t}=\\var{h^2*t}$$\\var{h}^2\\times\\var{t}=\\var{h^2*t}$$\\var{h}\\times\\var{t}^2=\\var{h*t^2}$
$X$$3$$2$$1$$1$
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
EventTHHTHTTTHTTT
Probability$\\var{h}^2\\times\\var{t}=\\var{h^2*t}$$\\var{h}\\times\\var{t}^2=\\var{h*t^2}$$\\var{h}\\times\\var{t}^2=\\var{h*t^2}$$\\var{t}^3=\\var{t^3}$
$X$$2$$1$$1$$0$
\n

So we see that:

\n

$P(X=0)=\\var{h0},\\;P(X=1)=\\var{h^2*t}+3\\times \\var{h*t^2}=\\var{h1}$

\n

$P(X=2)=2\\times \\var{h^2*t}=\\var{h2},\\;P(X=3)=\\var{h3}$

\n

b)

\n

The expectation is given by:

\n

$\\operatorname{E}[X]=\\sum x \\;P(X=x)=0\\times \\var{h0}+1\\times \\var{h1}+2\\times \\var{h2}+3\\times \\var{h3}=\\var{ex}$ (exactly).

\n

c)

\n

For this discrete distribution we use the formula:

\n

\\[\\begin{eqnarray*}\\operatorname{Var}(X)&=&\\operatorname{E}[X^2]-\\operatorname{E}(X)^2\\\\&=&0\\times \\var{h0}+1\\times \\var{h1}+4\\times \\var{h2}+9\\times \\var{h3}-\\var{ex}^2\\\\&=&\\var{var}\\end{eqnarray*}\\] to 4 decimal places.

", "rulesets": {}, "question_groups": [{"pickingStrategy": "all-ordered", "name": "", "pickQuestions": 0, "questions": []}], "functions": {}, "ungrouped_variables": ["h2", "h", "h0", "h1", "thismany", "t", "tol", "h3", "var", "ex"], "showQuestionGroupNames": false, "name": "XProbability mass function of string of heads from weighted coin,", "tags": ["checked2015", "counting", "discrete distribution", "discrete random variable", "expectation", "Probability", "probability", "probability mass function", "random variab;e", "runs", "sample space", "statistics", "variance"], "variablesTest": {"condition": "", "maxRuns": 100}, "variable_groups": [], "variables": {"var": {"name": "var", "definition": "precround(9*h3+4*h2+h1-ex^2,4)", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "thismany": {"name": "thismany", "definition": "3", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "tol": {"name": "tol", "definition": "0.0001", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "h": {"name": "h", "definition": "random(0.2..0.9#0.05 except 0.5)", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "h0": {"name": "h0", "definition": "t^3", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "ex": {"name": "ex", "definition": "3*h3+2*h2+h1", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "h1": {"name": "h1", "definition": "h^2*t+3*h*t^2", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "h3": {"name": "h3", "definition": "h^3", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "t": {"name": "t", "definition": "1-h", "group": "Ungrouped variables", "description": "", "templateType": "anything"}, "h2": {"name": "h2", "definition": "2*h^2*t", "group": "Ungrouped variables", "description": "", "templateType": "anything"}}, "statement": "

A coin has two faces, $H$ or $T$. It is weighted so that $P(H)=\\var{h}$ and $P(T)=\\var{t}$ and is tossed $\\var{thismany}$ times. 

\n

Let $X$ be the random variable which denotes the longest string of consecutive heads that occur during these tosses.

\n

Compute the:

\n

Probability Mass Function (PMF) of $X$.

\n

Expectation of $X$.

\n

Variance of $X$.

", "parts": [{"type": "gapfill", "scripts": {}, "variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

$X$ can take the values $0,\\;1,\\;2$ or $3$.

\n

Complete the tables below in order to find the PMF. You must input all numbers as exact decimals - no rounding or approximations.

\n

First, find the probability of each outcome on tossing the coin.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventHHHHHTHTHHTT
Probability[[0]][[1]][[2]][[3]]
$X$$3$$2$$1$$1$
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventTHHTHTTTHTTT
Probability[[4]][[5]][[6]][[7]]
$X$$2$$1$$1$$0$
\n

Use the information from the above table to find the PMF for $X$.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n
$X$$0$$1$$2$$3$
$P(X=x)$[[8]][[9]][[10]][[11]]
", "showCorrectAnswer": true, "gaps": [{"maxValue": "h^3", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "h^3", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "h^2*t", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "h^2*t", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "h^2*t", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "h^2*t", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "h*t^2", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "h*t^2", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "t*h^2", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "t*h^2", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "t^2*h", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "t^2*h", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "t^2*h", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "t^2*h", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "h0", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.25, "minValue": "h0", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "t^3", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.5, "minValue": "t^3", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "h1", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.5, "minValue": "h1", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "h2", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.5, "minValue": "h2", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}, {"maxValue": "h3", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 0.5, "minValue": "h3", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}], "variableReplacements": []}, {"type": "gapfill", "scripts": {}, "variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

Find the expectation:

\n

$\\operatorname{E}[X]=\\;$?[[0]] (input as an exact decimal).

", "showCorrectAnswer": true, "gaps": [{"maxValue": "ex", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 1, "minValue": "ex", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}], "variableReplacements": []}, {"type": "gapfill", "scripts": {}, "variableReplacementStrategy": "originalfirst", "marks": 0, "prompt": "

Find the variance:

\n

$\\operatorname{Var}(X)=\\;$[[0]] (to 4 decimal places).

", "showCorrectAnswer": true, "gaps": [{"maxValue": "var+tol", "showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "variableReplacementStrategy": "originalfirst", "marks": 1, "minValue": "var-tol", "showCorrectAnswer": true, "variableReplacements": [], "correctAnswerFraction": false}], "variableReplacements": []}], "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/"}]}