TransWikia.com

How to write the Gaussian Naive Bayes formula in latex?

TeX - LaTeX Asked on August 15, 2021

I am trying to compute the Gaussian Naive Bayes formula in latex, and what I obtained until now is:

$P(x_{mathrm{i}|$y$}) = frac{1}{{sigma sqrt {2pi } }}e^{{{ - left( {x - mu } right)^2 } mathord{left/ {vphantom {{ - left( {x - mu } right)^2 } {2sigma ^2 }}} right. kern-nulldelimiterspace} {2sigma ^2 }}}$

but I got some issues..

The final formula should look like this:

enter image description here

Can you help me please?

Thank you very much in advanced!!

2 Answers

Just alternative code using mid (to have symmetrical blank spaces instead of |) and exp commands.

documentclass[12pt]{article}
usepackage{amsmath}
usepackage{amssymb}

begin{document}

begin{equation*}
P(x_{i}mid y) = frac{1}{sqrt{2pi sigma_y^{2}}} exp left(-frac{(x_{i} -mu_{y})^2}{2sigma_y^{2}} right)
end{equation*}
end{document}

enter image description here

Correct answer by Sebastiano on August 15, 2021

Does this solve your question?

documentclass[]{article}
usepackage{amsmath}
begin{document}

begin{equation*}
P(x_i|y) = frac{1}{sqrt{2pi sigma_y^2}} exp left( - frac{(x_i - mu_y)^2}{2sigma_y^2} right)
end{equation*}
end{document}

You dont need the equation environment or the amsmath package. You could also simply replace your code with:

$P(x_i|y) = frac{1}{sqrt{2pi sigma_y^2}} exp left( - frac{(x_i - mu_y)^2}{2sigma_y^2} right)$

Answered by Armenthus on August 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP