// Numbas version: exam_results_page_options {"name": "Alex's copy of Construct a probability distribution function, then find CDF and expectation", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false}, "question_groups": [{"questions": [{"rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "question_groups": [{"questions": [], "pickingStrategy": "all-ordered", "pickQuestions": 0, "name": ""}], "variables": {"lx": {"group": "Ungrouped variables", "definition": "i1/2", "name": "lx", "description": "", "templateType": "anything"}, "e2": {"group": "Ungrouped variables", "definition": "4/p^2(((xu)^2/2*xu-xu^3/3)-((xu+xl)^2/2*xu-(xl+xu)^3/3))", "name": "e2", "description": "", "templateType": "anything"}, "ux": {"group": "Ungrouped variables", "definition": "j1/2", "name": "ux", "description": "", "templateType": "anything"}, "a": {"group": "Ungrouped variables", "definition": "0", "name": "a", "description": "", "templateType": "anything"}, "e1": {"group": "Ungrouped variables", "definition": "4/p^2*(((xu+xl)/2)^3-xl^3)/3", "name": "e1", "description": "", "templateType": "anything"}, "exans": {"group": "Ungrouped variables", "definition": "up-lo", "name": "exans", "description": "", "templateType": "anything"}, "tol": {"group": "Ungrouped variables", "definition": "0.01", "name": "tol", "description": "", "templateType": "anything"}, "p": {"group": "Ungrouped variables", "definition": "(xu-xl)", "name": "p", "description": "", "templateType": "anything"}, "ans": {"group": "Ungrouped variables", "definition": "precround(exans,2)", "name": "ans", "description": "", "templateType": "anything"}, "i1": {"group": "Ungrouped variables", "definition": "round((t+(100-t)*(xu-1))/100)", "name": "i1", "description": "", "templateType": "anything"}, "t": {"group": "Ungrouped variables", "definition": "random(0..100)", "name": "t", "description": "", "templateType": "anything"}, "u": {"group": "Ungrouped variables", "definition": "random(0..100)", "name": "u", "description": "", "templateType": "anything"}, "up": {"group": "Ungrouped variables", "definition": "precround(1-(2/p^2)*(ux-xu)^2,5)", "name": "up", "description": "", "templateType": "anything"}, "xu": {"group": "Ungrouped variables", "definition": "xl+random(4..15)", "name": "xu", "description": "", "templateType": "anything"}, "lo": {"group": "Ungrouped variables", "definition": "precround((2/p^2)*(lx-xl)^2,5)", "name": "lo", "description": "", "templateType": "anything"}, "j1": {"group": "Ungrouped variables", "definition": "round((u*(xu+1)+(100-u)*(2*xu-1))/100)", "name": "j1", "description": "", "templateType": "anything"}, "xl": {"group": "Ungrouped variables", "definition": "0", "name": "xl", "description": "", "templateType": "anything"}, "cval": {"group": "Ungrouped variables", "definition": "precround(4/p^2,4)", "name": "cval", "description": "", "templateType": "anything"}}, "name": "Alex's copy of Construct a probability distribution function, then find CDF and expectation", "variable_groups": [], "functions": {}, "ungrouped_variables": ["a", "e1", "ux", "xl", "i1", "lo", "j1", "up", "exans", "p", "u", "t", "tol", "ans", "e2", "cval", "lx", "xu"], "type": "question", "parts": [{"gaps": [{"showCorrectAnswer": true, "checkvariablenames": false, "scripts": {}, "notallowed": {"message": "

input as a fraction and not a decimal

", "partialCredit": 0, "showStrings": false, "strings": ["."]}, "checkingaccuracy": 0.001, "answersimplification": "std", "type": "jme", "expectedvariablenames": [], "vsetrange": [0, 1], "checkingtype": "absdiff", "answer": "{4}/{p^2}", "vsetrangepoints": 5, "marks": 2, "showpreview": true}], "showCorrectAnswer": true, "prompt": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $f_X(x) = \\left \\{ \\begin{array}{l} \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\\\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}}\\end{array} \\right .$ $0$ $x \\leq \\var{xl},$ $cx$ $\\var{xl} \\lt x \\leq \\simplify[std]{{xu+xl}/2},$ $c(\\var{xu}-x)$ $\\simplify[std]{{xu+xl}/2} \\lt x \\leq \\var{xu},$ $0$ $x \\gt \\var{xu}.$
\n \n \n \n

What value of $c$ makes $f_X(x)$ into the pdf of a distribution?

\n \n \n \n

Input your answer here as a fraction and not as a decimal.

\n \n \n \n

$c=\\;\\;$[[0]]

\n \n \n ", "scripts": {}, "marks": 0, "type": "gapfill"}, {"gaps": [{"showCorrectAnswer": true, "type": "jme", "scripts": {}, "checkingaccuracy": 0.001, "checkvariablenames": false, "expectedvariablenames": [], "vsetrange": [0, 1], "checkingtype": "absdiff", "answer": "0", "vsetrangepoints": 5, "marks": 0.5, "showpreview": true}, {"showCorrectAnswer": true, "checkvariablenames": false, "scripts": {}, "notallowed": {"message": "

input numbers as fractions or integers and not as decimals

", "partialCredit": 0, "showStrings": false, "strings": ["."]}, "checkingaccuracy": 0.001, "answersimplification": "std", "type": "jme", "expectedvariablenames": [], "vsetrange": [0, 1], "checkingtype": "absdiff", "answer": "(({2} / {(p ^ 2)}) * ((x + ( - {xl})) ^ 2))", "vsetrangepoints": 5, "marks": 1, "showpreview": true}, {"showCorrectAnswer": true, "checkvariablenames": false, "scripts": {}, "notallowed": {"message": "

input numbers as fractions or integers and not as decimals

", "partialCredit": 0, "showStrings": false, "strings": ["."]}, "checkingaccuracy": 0.001, "answersimplification": "std", "type": "jme", "expectedvariablenames": [], "vsetrange": [0, 1], "checkingtype": "absdiff", "answer": "(1 + ( - (({2} / {(p ^ 2)}) * ((x + ( - {xu})) ^ 2))))", "vsetrangepoints": 5, "marks": 1, "showpreview": true}, {"showCorrectAnswer": true, "type": "jme", "scripts": {}, "checkingaccuracy": 0.001, "checkvariablenames": false, "expectedvariablenames": [], "vsetrange": [0, 1], "checkingtype": "absdiff", "answer": "1", "vsetrangepoints": 5, "marks": 0.5, "showpreview": true}], "showCorrectAnswer": true, "prompt": "\n \n \n

Given the value of $c$ found in the first part, determine and input the distribution function $F_X(x)$

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
 $F_X(x) = \\left \\{ \\begin{array}{l} \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}}\\\\ \\phantom{{.}}\\\\ \\phantom{{.}} \\end{array} \\right .$ [[0]] $x \\leq \\var{xl},$ [[1]] $\\var{xl} \\lt x \\leq \\simplify[std]{{xu+xl}/2},$ [[2]] $\\simplify[std]{{xu+xl}/2} \\lt x \\leq \\var{xu},$ [[3]] $x \\gt \\var{xu}.$
\n \n \n \n

Input all numbers as fractions or integers in the above formulae.

\n \n \n ", "scripts": {}, "marks": 0, "type": "gapfill"}, {"gaps": [{"showCorrectAnswer": true, "allowFractions": false, "scripts": {}, "maxValue": "ans+tol", "correctAnswerFraction": false, "minValue": "ans-tol", "showPrecisionHint": false, "type": "numberentry", "marks": 1}], "showCorrectAnswer": true, "prompt": "\n \n \n

Also, using the distribution function above find:

\n \n \n \n

$P(\\var{lx} \\lt X \\lt \\var{ux})=\\;\\;$[[0]]

\n \n \n \n

(input your answer to $2$ decimal places).

\n \n \n ", "scripts": {}, "marks": 0, "type": "gapfill"}, {"gaps": [{"showCorrectAnswer": true, "checkvariablenames": false, "scripts": {}, "notallowed": {"message": "

Input your answer as an integer or a fraction and not as a decimal.

", "partialCredit": 0, "showStrings": false, "strings": ["."]}, "checkingaccuracy": 0.001, "answersimplification": "all,fractionNumbers", "type": "jme", "expectedvariablenames": [], "vsetrange": [0, 1], "checkingtype": "absdiff", "answer": "{xu}/2", "vsetrangepoints": 5, "marks": 1, "showpreview": true}], "showCorrectAnswer": true, "prompt": "

Hence find the expectation

\n

$\\displaystyle \\operatorname{E}[X]=\\int_{-\\infty}^{\\infty}xf_X(x)\\;dx$.

\n

$\\operatorname{E}[X]\\;=\\;$[[0]]

\n

", "scripts": {}, "marks": 0, "type": "gapfill"}], "variablesTest": {"maxRuns": 100, "condition": ""}, "statement": "

A random variable $X$ has a probability density function (PDF) given by:

", "preamble": {"css": "", "js": ""}, "tags": ["CFD", "checked2015", "continuous random variables", "cr1", "cumulative distribution functions", "density functions", "distribution function", "distribution functions", "expectation", "integration", "MAS8380", "PDF", "pdf", "piecewise function", "probabilities", "probability density function", "random variables", "statistics", "tested1"], "advice": "

a)
Note that in order for $f_X(x)$ to be a pdf it must satisfy two important conditions:

\n

1. $f_X(x) \\ge 0$ in the range $\\var{xl} \\le x \\le \\var{xu}$

\n

2. The area under the curve given by $f_X(x)$ is $1$ and this implies that:
\$\\int_{\\var{xl}}^{\\var{xu}}f_X(x)\\;dx = 1\$ as the value of the function is $0$ outside this range.

\n

We first check condition 2. and then check that condition 1. is satisfied.

\n

Hence \$\\begin{eqnarray*} \\int_{-\\infty}^{\\infty}f_X(x)\\;dx=\\int_{\\var{xl}}^{\\var{xu}}f_X(x)\\;dx&=&\\int_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}}cx\\;dx+\\int_{\\simplify[std]{{xu+xl}/2}}^{\\var{xu}}c(\\var{xu}-x)\\;dx\\\\ &=&c \\left[ \\frac{x^2}{2} \\right]_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}} + c\\left[\\var{xu}x - \\frac{x^2}{2}\\right]_{\\simplify[std]{{xu+xl}/2}}^{\\var{xu}}\\\\&=&\\simplify[std]{{(xu+xl)^2}/8}c+\\simplify[std]{{(xu-xl)^2}/8}c=\\simplify[std]{{xu^2+{xl^2}}/{4}}c \\end{eqnarray*} \$

\n

But this has to equal $1$ and so \$c=\\simplify[std]{4/{p^2}}\$

\n

Hence with this value of $c$ we see that condition 2. is satisfied i.e.

\n

\$\\int_{-\\infty}^{\\infty}f_X(x)\\;dx=1\$

\n

Condition 1. is clearly satisfied as $c \\gt 0$.

\n

b)

\n

The Distribution Function

\n

We must have $F_X(x)=0,\\;\\;\\;x \\le \\var{xl},\\;\\;\\;\\textrm{and}\\;\\;\\;F_X(x)=1,\\;\\;\\;x \\ge \\var{xu}$

\n

Apart from that we find an expression for $F_X(x)$ in each of the ranges $[\\var{xl},\\simplify[std]{{xl+xu}/2}],\\;\\;\\;[\\simplify[std]{{xl+xu}/2},\\var{xu}]$

\n

1. $x \\in [\\var{xl},\\simplify[std]{{xl+xu}/2}]$

\n

We have:\$\\begin{eqnarray*} f_X(x) &=& \\simplify[std]{{4}/{p^2}} x \\\\ \\Rightarrow F_X(x)&=& \\int_{-\\infty}^xf_X(u)\\;du \\\\ &=& \\simplify[std]{{4}/{p^2}}\\int_{\\var{xl}}^x u\\;du\\\\ &=&\\simplify[std]{{4}/{p^2}}\\left[\\frac{u^2}{2}\\right]_{\\var{xl}}^x\\\\&=&\\simplify[std]{{2}/{p^2}}x^2 \\end{eqnarray*} \$

\n

2. $x \\in [\\simplify[std]{{xl+xu}/2},\\var{xu}]$

\n

We have:\$\\begin{eqnarray*} f_X(x) &=& \\simplify[std]{{4}/{p^2}}(\\var{xu}-x) \\\\ \\Rightarrow F_X(x)&=& \\int_{-\\infty}^xf_X(u)\\;du = \\int_{\\var{xl}}^{\\simplify[std]{{xl+xu}/2}}f_X(u)\\;du+\\int_{\\simplify[std]{{xl+xu}/2}}^x f_X(u)\\;du\\\\ &=& \\simplify[std]{{4}/{p^2}}\\int_{\\var{xl}}^{\\simplify[std]{{xl+xu}/2}} u\\;du + \\simplify[std]{{4}/{p^2}}\\int_{\\simplify[std]{{xl+xu}/2}}^x(\\var{xu}-u)\\;du\\\\&=&\\simplify[std]{{4}/{p^2}}\\left[ \\frac{u^2}{2} \\right]_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}} + \\simplify[std]{{4}/{p^2}}\\left[\\var{xu}u - \\frac{u^2}{2}\\right]_{\\simplify[std]{{xu+xl}/2}}^x\\\\&=&1-\\simplify[std]{{2}/{p^2}}(\\var{xu}-x)^2 \\end{eqnarray*} \$

\n

c)

\n

Probability

\n

Using the distribution function we have just found we have that:

\n

$P(\\var{lx} \\lt X \\lt \\var{ux}) = F_X(\\var{ux})-F_X(\\var{lx})$

\n

But $\\var{ux}$ is in the range between $\\var{(xl+xu)/2}$ and $\\var{xu}$ and the distribution function is given by:

\n

\$F_X(x)=1-\\simplify[std]{{2}/{p^2}}(\\var{xu}-x)^2\$

\n

Hence $F_X(\\var{ux})=1-\\simplify[std]{{2}/{p^2}}(\\var{xu}-\\var{ux})^2 = \\var{up}$ to 5 decimal places.

\n

Similarly, $\\var{lx}$ is in the range between $\\var{xl}$ and $\\var{(xl+xu)/2}$ and the distribution function is given by:

\n

\$F_X(x)=\\simplify[std]{{2}/{p^2}}x^2\$

\n

Hence $F_X(\\var{lx})=\\simplify[std]{{2}/{p^2}}(\\var{lx})^2 = \\var{lo}$ to 5 decimal places.

\n

Hence $P(\\var{lx} \\lt X \\lt \\var{ux}) = F_X(\\var{ux})-F_X(\\var{lx})=\\var{up}-\\var{lo}=\\var{up-lo}=\\var{ans}$ to 2 decimal places.

\n

Expectation.

\n

d) The expectation is given by  $\\displaystyle \\operatorname{E}[X]=\\int_{-\\infty}^{\\infty}xf_X(x)\\;dx$.

\n

As $f_X(x)=0$ for $x \\le \\var{xl}$ and $x \\ge \\var{xu}$ we see that:

\n

\\\begin{align}\\operatorname{E}[X]= \\int_{-\\infty}^{\\infty}xf_X(x)\\;dx &= \\int_{\\var{xl}}^{\\simplify[std]{{(xu+xl)}/2}}xf_X(x)\\;dx+ \\int_{\\simplify[std]{{(xu+xl)}/2}}^{\\var{xu}}xf_X(x)\\;dx\\\\&= c\\int_{\\var{xl}}^{\\simplify[std]{{(xu+xl)}/2}}x^2\\;dx+c\\int_{\\simplify[std]{{(xu+xl)}/2}}^{\\var{xu}}x({\\var{xu}-x)}\\;dx\\\\&=c \\left[ \\frac{x^3}{3} \\right]_{\\var{xl}}^{\\simplify[std]{{xu+xl}/2}} + c\\left[\\var{xu}\\frac{x^2}{2} - \\frac{x^3}{3}\\right]_{\\simplify[std]{{xu+xl}/2}}^{\\var{xu}}\\\\&=c\\times\\simplify[std]{{xu}^3/24}+c\\times \\simplify[std]{{xu}^3/12}\\\\&=\\simplify[std]{{xu}/2}\\end{align}\

\n

on remembering that $\\displaystyle c=\\simplify[std]{4/{p^2}}$

", "showQuestionGroupNames": false, "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1273/", "name": "Alex Van den Hof"}], "metadata": {"notes": "

8/07/2012:

\n

\n

Checked calculations, OK.

\n

Set tolerance via new variable tol=0.01 for last question.

\n

23/07/2012:

\n

\n

1/08/2012:

\n

\n

In the Advice section, moved \\Rightarrow to the beginning of the line instead of the end of the previous line.

\n

Question appears to be working correctly.

\n

21/12/2012:

\n

Checked calculations, OK. Added tag tested1.

\n

Checked rounding, OK. Added tag cr1.

", "licence": "Creative Commons Attribution 4.0 International", "description": "

The random variable $X$ has a PDF which involves a parameter $c$. Find the value of $c$. Find the distribution function $F_X(x)$ and $P(a \\lt X \\lt b)$.

\n

Also find the expectation $\\displaystyle \\operatorname{E}[X]=\\int_{-\\infty}^{\\infty}xf_X(x)\\;dx$.

"}}], "pickingStrategy": "all-ordered"}], "contributors": [{"profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1273/", "name": "Alex Van den Hof"}]}