Does anybody know the way to construct a Bayesian classifier in R for two bi-variate gaussian distributions of which the means and variances are known? The two classes are equi-probable and the variables are independent from each other.

Any help is deeply appreciated.

  • 1
    $\begingroup$ We already answered that in your other post stats.stackexchange.com/questions/24772/… . You just have to check inequality (*). What is the deal of doing that? $\endgroup$
    – Zen
    Mar 19, 2012 at 19:44
  • $\begingroup$ Hi, thanks for the comment. What you mean is, that I need to do the entire set of steps in deriving the Bayesian classifier as you showed in the above post in R too? I am interested in knowing whether there is a method specific to R in doing that here. $\endgroup$
    – picmate
    Mar 20, 2012 at 21:59

1 Answer 1


When you have known means / variances, this classifier amounts to just finding the likelihood of your sample under the two models and choosing the one that's greater. I don't use R, but it looks like dnorm2d or dmvnorm will find likelihoods for you; dnorm2d is bivariate-specific but you have to subtract the mean off and maybe divide by sigmas yourself, while dmvnorm will do those for you but you have to make the 2x2 covariance matrix yourself.

I'm not sure what you mean by the variables being independent: that you're dealing with IID samples of pairs, or that the two elements of the vector are independent? In the latter case, you could also just use 1D normal likelihoods and multiply them.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.