Wednesday, March 4, 2009

some latex constructs

here are some common constructs i use that i find myself frequently looking up. the first is the parallel symbol used in the Kullback-Leibler divergence. just using a pair of vertical bars squeezes the arguments together, but the \parallel puts the necessary space before and after the bars. below is the definition of skewed Kullback-Leibler divergence.


D_{SKL}(p,q) = D_{KL}\left(p \parallel \gamma p + (1-\gamma)q\right)


a similar problem occurs with conditional probabilities. \mid takes care of that. the next example uses Bayes' theorem, with a little \frac business for flavor.


P(A \mid B)=\frac{P(B \mid A)P(A)}{P(B)}


i use an old homework to show how to used the cases environment. each line can have only 1 &, which separating the result and the condition. not that the "amsmath" package needs to be loaded, or else you'll get funky "Misplaced alignment tab character &" errors. i use the \text command to get normal script in the math environment. (in the homework, i was referring to Prototype-driven grammar induction, by Haghighi and Klein)


P(p_{ij} \mid X) =
\begin{cases}
0.6 & \text{if $p_{ij}=X$}\\
\text{uniform} & \text{otherwise}
\end{cases}


that's it for now. if any latex stuff comes up, and i think it's interesting (or that i might need it for future reference), i'll be posting.

No comments:

Post a Comment