// Numbas version: exam_results_page_options {"name": "Kma's copy of 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": [{"functions": {}, "ungrouped_variables": ["prod", "mle", "m", "x1", "sumsq", "tol", "x3", "x2", "x", "y2", "where"], "name": "Kma's copy of Log-likelihood and maximum likelihood estimator for PDF", "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"], "type": "question", "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)

\n

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*} \\]

\n

c)

\n

We 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}$

\n

d)
\\[\\frac{\\partial^2\\;l}{\\partial\\;t^2}=-3t^{-2} \\lt 0\\]
when evaluated at any point including $t=\\hat{t}=\\var{mle}$.

\n

Hence gives a maximum at $t=\\hat{t}$.

", "rulesets": {"std": ["all", "fractionNumbers", "!collectNumbers", "!noLeadingMinus"]}, "parts": [{"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, "gaps": [{"expectedvariablenames": [], "checkingaccuracy": 0.001, "type": "jme", "showpreview": true, "vsetrangepoints": 5, "showCorrectAnswer": true, "answersimplification": "std", "scripts": {}, "answer": "({(8 *prod)} * (t ^ 3) * Exp(({( - sumsq)} * t)))", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "vsetrange": [-0.2, -0.1]}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}, {"prompt": "

Hence find the log-likelihood function for $t$

\n

$l(t|\\underline{x})=\\;\\;$[[0]]

\n

If $\\ln(a)$, for some integer $a$, is a term in your answer, leave as $\\ln(a)$ and do not evaluate.

", "marks": 0, "gaps": [{"expectedvariablenames": [], "checkingaccuracy": 0.001, "type": "jme", "showpreview": true, "vsetrangepoints": 5, "showCorrectAnswer": true, "answersimplification": "std", "scripts": {}, "answer": "(Ln({(8 * prod)}) + (3 * Ln(t)) - ({sumsq} * t))", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "vsetrange": [0, 1]}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}, {"prompt": "

Find the MLE $\\hat{t}$ for $t$

\n

$\\hat{t}=\\;\\;$[[0]]

\n

Input to 2 decimal places.

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

Now verify that you have indeed found a maximum:

\n

1. First find $\\displaystyle\\frac{\\partial^2\\;l}{\\partial\\;t^2}=\\;\\;$[[0]].

\n

2. 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]].

\n

Input to 2 decimal places.

", "marks": 0, "gaps": [{"expectedvariablenames": [], "checkingaccuracy": 0.001, "type": "jme", "showpreview": true, "vsetrangepoints": 5, "showCorrectAnswer": true, "answersimplification": "std", "scripts": {}, "answer": "-(3/t^2)", "marks": 1, "checkvariablenames": false, "checkingtype": "absdiff", "vsetrange": [0, 1]}, {"allowFractions": false, "scripts": {}, "maxValue": "m+tol", "minValue": "m-tol", "correctAnswerFraction": false, "showCorrectAnswer": true, "marks": 1, "showPrecisionHint": false, "type": "numberentry"}], "showCorrectAnswer": true, "scripts": {}, "type": "gapfill"}], "preamble": {"css": "", "js": ""}, "statement": "

The average annual wind speed, $X$, at {where} has the following probability density function with parameter $t$ which you have to estimate:

\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{{.}} \\end{array} \\right .$$2txe^{-tx^2}$$x \\gt 0,$
  
$0$$\\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}$.

", "variable_groups": [], "variablesTest": {"maxRuns": 100, "condition": ""}, "question_groups": [{"pickingStrategy": "all-ordered", "name": "", "questions": [], "pickQuestions": 0}], "variables": {"prod": {"definition": "x1*x2*x3", "templateType": "anything", "group": "Ungrouped variables", "name": "prod", "description": ""}, "mle": {"definition": "precround(3/sumsq,2)", "templateType": "anything", "group": "Ungrouped variables", "name": "mle", "description": ""}, "m": {"definition": "-precround(3/mle^2,2)", "templateType": "anything", "group": "Ungrouped variables", "name": "m", "description": ""}, "x1": {"definition": "random(2.5..5.5#0.5)", "templateType": "anything", "group": "Ungrouped variables", "name": "x1", "description": ""}, "sumsq": {"definition": "x1^2+x2^2+x3^2", "templateType": "anything", "group": "Ungrouped variables", "name": "sumsq", "description": ""}, "tol": {"definition": "0", "templateType": "anything", "group": "Ungrouped variables", "name": "tol", "description": ""}, "x3": {"definition": "random(2.5..7.5#0.5)", "templateType": "anything", "group": "Ungrouped variables", "name": "x3", "description": ""}, "x2": {"definition": "if(y2=x1,y2+ random(-1..1#0.5),y2)", "templateType": "anything", "group": "Ungrouped variables", "name": "x2", "description": ""}, "x": {"definition": "x1+x2+x3", "templateType": "anything", "group": "Ungrouped variables", "name": "x", "description": ""}, "y2": {"definition": "random(3.5..6.5#0.5)", "templateType": "anything", "group": "Ungrouped variables", "name": "y2", "description": ""}, "where": {"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')", "templateType": "anything", "group": "Ungrouped variables", "name": "where", "description": ""}}, "showQuestionGroupNames": false, "metadata": {"notes": "

14/07/2012:

\n

Added tags.

\n

Corrected mistakes in Advice.

\n

Added some text to make statement clearer re parameter $t$.

\n

Rephrased questions in last question so that it is clear that the value to 2dps is used in the calculation.

\n

Spaced Advice text.

\n

New tolerance variable,  tol=0 for last two questions.

\n

Added line in prompt: If $\\ln(a)$, for some integer $a$, is a term in your answer, leave as $\\ln(a)$ and do not evaluate.

\n

Improved display of correct answer in second question as $+\\;- $ together. Also improved correct answer display in second last question.

\n

Important: 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.

\n

1/08/2012:

\n

Added tags.

\n

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

\n

21/12/2012:

\n

Checked calculations, OK. Added tested1 tag.

\n

Checked rounding, OK. Added cr1 tag.

\n

Scenarios, so added sc tag.

", "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$. 

", "licence": "Creative Commons Attribution 4.0 International"}, "contributors": [{"name": "Kma math", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1271/"}]}]}], "contributors": [{"name": "Kma math", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/1271/"}]}