I'm not sure how I should go about this question. I've tried looking through my lecture notes but can't seem to find any way of figuring out this question

question link


closed as off-topic by egreg, Gibbs, Lord Shark the Unknown, Lee David Chung Lin, Kemono Chen Feb 7 at 9:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – egreg, Gibbs, Lord Shark the Unknown, Lee David Chung Lin, Kemono Chen
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Please TeX the question into your post, since the link to the image may brake in the future, making your post incomprehensible. Regards, $\endgroup$ – Pedro Tamaroff Feb 6 at 16:01

Use Bayes' theorem - https://en.wikipedia.org/wiki/Bayes%27_theorem

You know $p(x|y)$ .Also you need the priors ,$p(y)$ . Since you don't have this information , I assume that $p(y=0) = p(y=1) = 1/2$ . Then you can compute $p(x)$ - https://en.wikipedia.org/wiki/Law_of_total_probability .

  • $\begingroup$ Thank you! I knew I had to use Bayes to work out the p(x|y), but what I'm confused about is the mu_0 and sigma_0. What values from the expressions of mu_0 and sigma_0 do I use in the normal distribution to find p(x|y=0) (and vice versa for mu_1, sigma_1 and p(x|y=1))? And yes, I'm assuming the priors are 1/2 each, since I am not told otherwise $\endgroup$ – user641579 Feb 6 at 14:56
  • $\begingroup$ @J.Smith since x is a vector you need to use the multivariate normal distribution (see Wikipedia), which expects $\mu$ to be a vector and $\Sigma$ to be a matrix. $\endgroup$ – Alex Feb 6 at 15:17

As @Popescu mentioned, you have to compute two probabilities for each class ($p(x|y_0)*p(y=0)$ and $p(x|y_1)*p(y=1)$). Your predicted class is the one that maximizes the probability: Here is the code in python:

import numpy as np
from scipy.stats import multivariate_normal

##Priors (assumption since its not given)
y_0 = 0.5
y_1 = 0.5

cov0= np.array([[0.5,4.5],[4.5,140]])
mean0 = [6.2,25.1]

cov1= np.array([[0.3,41.2],[1.2,30]])
mean1 = [7.3,32.4]

x = [6.8,30.1]

p0 = multivariate_normal.pdf(x, mean=mean0, cov=cov0)*y_0

p1 = multivariate_normal.pdf(x, mean=mean1, cov=cov1)*y_1

p1 = 0.01904

p0 = 0.00786

So your prediction should be 1 since p1>p0