1

I have a discrete probability distribution p(x) with the support ${\mathcal {X}} = {0,1,2,3,4,5,6,7,8,9}$ and I'd like to represent the distribution in the form of a table, similar to the one below

enter image description here

How do I do the job with latex?

JJJohn
  • 556
  • Maybe an automated version could be useful here. This should be very easy to do with LaTeX3 or simply with NiceMatrix. I keep it in mind... – projetmbc Jul 22 '21 at 08:24
  • Today, vertical rules in tables are considered bad style. – Gaussler Jul 22 '21 at 08:38
  • @Gaussler Thank you. So, what style is suggested? – JJJohn Jul 22 '21 at 08:52
  • @JJJohn Only horizontal rules, and only at the top, bottom, and at a few important places in between. Try looking at the package booktabs, they show the modern standard looks and how to produce it. – Gaussler Jul 22 '21 at 09:30

1 Answers1

3

If the two columns are supposed to be equally wide, use the first of the two approaches shown below; if not, use the second approach.

enter image description here

\documentclass{article}
\usepackage{array} % for 'w' column type
\begin{document}
\[
\begin{array}{w{c}{8mm}|w{c}{8mm}}
x & P(x) \\
\hline
2 & 1/16 \\
3 & 2/16 \\
4 & 3/16 \\
5 & 4/16 \\
6 & 3/16 \\
7 & 2/16 \\
8 & 1/16 
\end{array}
\qquad
\begin{array}{c|c}
x & P(x) \\
\hline
2 & 1/16 \\
3 & 2/16 \\
4 & 3/16 \\
5 & 4/16 \\
6 & 3/16 \\
7 & 2/16 \\
8 & 1/16 
\end{array}
\]
\end{document}
Mico
  • 506,678