Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help code the following in python. Thank you. First, write a function that will compute the likelihood for a single x and y observation,

Please help code the following in python. Thank you.

image text in transcribedimage text in transcribed

First, write a function that will compute the likelihood for a single x and y observation, as a function of some estimate of ] def likelihood(theta_hat, x,y) : " "The likelihood function for a linear model with noise sampled from a Gausian distribution with zero mean and unit variance. Args: theta_hat (float): An estimate of the slope parameter. x (ndarray): A scalar that contains the input ralue. y (ndarray): A scalar that contains the corresponding measurement values to the input. Returns: ndarray: the likelihood values for the theta hat estimate " " sigma = 1 \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# \#\# Compute Gaussian likelihood below for single sample \#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\# Let us first consider a single obersvation of x and y. Say, for simplicity, x=2.1 and y=3.7. Verify that, for this single observation, L(=1.0x=2.1,y=3.7)0.11 using your function above. [ ] \#\#\#\# Write your code When dealing with a set or vector of data points, as we are with our full dataset, we are concerned with their joint probability -- the likelihood that all data points are explained by our parameterization. Since we have assumed that the noise affects each output independently, we can factorize the likelihood, and write: L(x,y)=i=1NL(xi,yi), where we have N data points x=[x1,,xN] and y=[y1,,yN]. - In practice, such a product can be numerically unstable. Indeed, multiplying small values together can lead to arithmetic underflow. This problem can be circumvented by taking the logarithm of the likelihood because the logarithm transforms products into sums: logL(x,y)=i=1NlogL(xi,yi)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

When is it appropriate to show grace toward others?

Answered: 1 week ago

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago

Question

=+ Is secondary industrial action common and/or legal?

Answered: 1 week ago

Question

=+What sanctions are available to employers

Answered: 1 week ago