// Numbas version: finer_feedback_settings {"name": "Log-likelihood and maximum likelihood estimator for PDF", "extensions": ["stats"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [], "variables": {"x": {"templateType": "anything", "group": "Ungrouped variables", "definition": "x1+x2+x3", "description": "", "name": "x"}, "tol": {"templateType": "anything", "group": "Ungrouped variables", "definition": "0", "description": "", "name": "tol"}, "x1": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2.5..5.5#0.5)", "description": "", "name": "x1"}, "prod": {"templateType": "anything", "group": "Ungrouped variables", "definition": "x1*x2*x3", "description": "", "name": "prod"}, "m": {"templateType": "anything", "group": "Ungrouped variables", "definition": "-precround(3/mle^2,2)", "description": "", "name": "m"}, "where": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random('North Shields','Owslebury','Bradfield in West Yorkshire','Sheffield','Windy Nook', 'Hepple','Leeming','Linton-on-Ouse','Scampton','Cranwell','Keele','Bingley', 'Ecclefechan','Finningley','Foxrock, Dublin')", "description": "", "name": "where"}, "x2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "if(y2=x1,y2+ random(-1..1#0.5),y2)", "description": "", "name": "x2"}, "y2": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(3.5..6.5#0.5)", "description": "", "name": "y2"}, "sumsq": {"templateType": "anything", "group": "Ungrouped variables", "definition": "x1^2+x2^2+x3^2", "description": "", "name": "sumsq"}, "x3": {"templateType": "anything", "group": "Ungrouped variables", "definition": "random(2.5..7.5#0.5)", "description": "", "name": "x3"}, "mle": {"templateType": "anything", "group": "Ungrouped variables", "definition": "precround(3/sumsq,2)", "description": "", "name": "mle"}}, "ungrouped_variables": ["prod", "mle", "m", "x1", "sumsq", "tol", "x3", "x2", "x", "y2", "where"], "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "name": "Log-likelihood and maximum likelihood estimator for PDF", "functions": {}, "showQuestionGroupNames": false, "parts": [{"scripts": {}, "gaps": [{"answer": "({(8 *prod)} * (t ^ 3) * Exp(({( - sumsq)} * t)))", "vsetrange": [-0.2, -0.1], "scripts": {}, "checkvariablenames": false, "expectedvariablenames": [], "showpreview": true, "checkingtype": "absdiff", "checkingaccuracy": 0.001, "answersimplification": "std", "type": "jme", "showCorrectAnswer": true, "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "\n \n \n
Find the likelihood function for $t$ given these observations.
\n \n \n \n$L(t|\\underline{x})=\\;\\;$[[0]]
\n \n ", "marks": 0}, {"scripts": {}, "gaps": [{"answer": "(Ln({(8 * prod)}) + (3 * Ln(t)) - ({sumsq} * t))", "vsetrange": [0, 1], "scripts": {}, "checkvariablenames": false, "expectedvariablenames": [], "showpreview": true, "checkingtype": "absdiff", "checkingaccuracy": 0.001, "answersimplification": "std", "type": "jme", "showCorrectAnswer": true, "marks": 1, "vsetrangepoints": 5}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "Hence find the log-likelihood function for $t$
\n$l(t|\\underline{x})=\\;\\;$[[0]]
\nIf $\\ln(a)$, for some integer $a$, is a term in your answer, leave as $\\ln(a)$ and do not evaluate.
", "marks": 0}, {"scripts": {}, "gaps": [{"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "minValue": "mle-tol", "showCorrectAnswer": true, "marks": 1, "maxValue": "mle+tol"}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "Find the MLE $\\hat{t}$ for $t$
\n$\\hat{t}=\\;\\;$[[0]]
\nInput to 2 decimal places.
", "marks": 0}, {"scripts": {}, "gaps": [{"answer": "-(3/t^2)", "vsetrange": [0, 1], "scripts": {}, "checkvariablenames": false, "expectedvariablenames": [], "showpreview": true, "checkingtype": "absdiff", "checkingaccuracy": 0.001, "answersimplification": "std", "type": "jme", "showCorrectAnswer": true, "marks": 1, "vsetrangepoints": 5}, {"showPrecisionHint": false, "scripts": {}, "allowFractions": false, "type": "numberentry", "correctAnswerFraction": false, "minValue": "m-tol", "showCorrectAnswer": true, "marks": 1, "maxValue": "m+tol"}], "type": "gapfill", "showCorrectAnswer": true, "prompt": "Now verify that you have indeed found a maximum:
\n1. First find $\\displaystyle\\frac{\\partial^2\\;l}{\\partial\\;t^2}=\\;\\;$[[0]].
\n2. Using the value of the MLE to 2 decimal places you have found:
\n$\\displaystyle\\frac{\\partial^2\\;l}{\\partial\\;t^2}$ evaluated at $\\hat{t}$ = [[1]].
\nInput to 2 decimal places.
", "marks": 0}], "statement": "The average annual wind speed, $X$, at {where} has the following probability density function with parameter $t$ which you have to estimate:
\n$f_X(x) = \\left \\{ \\begin{array}{l} \\phantom{{.}} \\\\ \\phantom{{.}} \\\\ \\phantom{{.}} \\end{array} \\right .$ | \n$2txe^{-tx^2}$ | \n$x \\gt 0,$ | \n
\n | \n | |
$0$ | \n$\\textrm{otherwise.}$ | \n
For three randomly selected years, we observe the following average wind speeds:
\n$x_1=\\var{x1},\\;\\;x_2=\\var{x2}$ and $x_3=\\var{x3}$.
", "tags": ["checked2015", "cr1", "density function", "estimators", "likelihood functions", "log-likelihood function", "maximum", "maximum likelihood estimator", "mle", "MLE", "PDF", "pdf", "Probability", "probability", "probability density function", "random sample", "random variable", "sc", "second derivative", "statistics", "tested1", "unused"], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "14/07/2012:
\nAdded tags.
\nCorrected mistakes in Advice.
\nAdded some text to make statement clearer re parameter $t$.
\nRephrased questions in last question so that it is clear that the value to 2dps is used in the calculation.
\nSpaced Advice text.
\nNew tolerance variable, tol=0 for last two questions.
\nAdded line in prompt: If $\\ln(a)$, for some integer $a$, is a term in your answer, leave as $\\ln(a)$ and do not evaluate.
\nImproved display of correct answer in second question as $+\\;- $ together. Also improved correct answer display in second last question.
\nImportant: set checking range between -0.2 and -0.1 rather than between 0 and 1 so that evaluation of likelihood function over the range does not suffer from underflow and incorrect answer marked as correct. This needs constant testing, have tested on bounday values and OK.
\n1/08/2012:
\nAdded tags.
\nIn the Advice section, moved \\Rightarrow to the beginning of the line instead of the end of the previous line.
\n21/12/2012:
\nChecked calculations, OK. Added tested1 tag.
\nChecked rounding, OK. Added cr1 tag.
\nScenarios, so added sc tag.
", "licence": "Creative Commons Attribution 4.0 International", "description": "Given a PDF $f(x)$ on the real line with unknown parameter $t$ and three random observations, find log-likelihood and MLE $\\hat{t}$ for $t$.
"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "a)
\n\\[ \\begin{eqnarray*} L(t|\\underline{x})&=& \\var{2*x1}te^{-\\var{x1}^2t}\\times \\var{2*x2}te^{-\\var{x2}^2t} \\times \\var{2*x3}te^{-\\var{x3}^2t}\\\\ &=& \\var{8*prod}t^3e^{-\\var{sumsq}t} \\end{eqnarray*} \\]
b)
The log-likelihood function is :
\\[\\begin{eqnarray*} l(t|\\underline{x})&=&\\ln\\left( \\var{8*prod}t^3e^{-\\var{sumsq}t}\\right)\\\\ &=&\\ln(\\var{8*prod})+3\\ln(t)-\\var{sumsq}t \\end{eqnarray*} \\]
c)
\nWe have:
\\[\\frac{\\partial\\;l}{\\partial\\;t}=\\frac{3}{t}-\\var{sumsq}\\]
Now:
\\[\\begin{eqnarray*} \\frac{\\partial\\;l}{\\partial\\;t}&=&0 \\\\ \\Rightarrow \\frac{3}{t}-\\var{sumsq}&=&0\\\\ \\Rightarrow t&=&\\frac{3}{\\var{sumsq}} = \\var{mle} \\end{eqnarray*} \\] to 3 decimal places.
And putting $t=\\hat{t}$ gives the MLE $\\hat{t}=\\var{mle}$
d)
\\[\\frac{\\partial^2\\;l}{\\partial\\;t^2}=-3t^{-2} \\lt 0\\]
when evaluated at any point including $t=\\hat{t}=\\var{mle}$.
Hence gives a maximum at $t=\\hat{t}$.
", "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}