I'm need a symbol for "independence" in probability, that could take parameters, so it is probability over a $\sigma$-algebra. I don't know how to describe it, so I wrote it by hand. I've seen people create something similar for the independence by non-forking extensiosn. Is there a way to create a symbol that behaves like this?
4 Answers
The newtx
and newpx
text and math font packages provide a macro called \Perp
that can be used to create a relational operator I'll call \prind
-- short for "probability independence", I suppose.
\documentclass{article} % or some other suitable document class
\usepackage{amsmath}
\usepackage{newpx} % or: \usepackage{newtx}
\newcommand{\prind}{\mathrel{\Perp}}
% Use in displaystyle math mode ("limits" below symbol)
\newcommand{\dprind}[1]{\mathrel{\mathop{\Perp}\limits_{#1}}}
\begin{document}
$a \prind b \quad a \prind_C b \quad \displaystyle a \dprind{C} b$
\end{document}
What to do if you can't use either the newtx
or newpx
font package to access a ready-made \Perp
macro? Easy: Just "roll your own" \Perp
macro, along the lines of either @SandyG's answer or of @egreg's recent answer, which defines \Perp
as
\newcommand{\Perp}{\mathrel{\perp\mspace{-9mu}\perp}}
The ⫫ symbol is \Vbar
in unicode-math
, or the legacy packages stix
, stix2
and fdsymbol
.
\documentclass{article}
\usepackage[default]{fontsetup} % Loads unicode-math.
\begin{document}
\begin{align*}
a &\Vbar b \\
a &\Vbar_C b \\
a &\mathrel{\mathop\Vbar\limits_{C}} b
\end{align*}
\end{document}
On PDFLaTeX, replace fontsetup
with \usepackage{amsmath, stix2}
.
You can use the standard _{C}
syntax.
\documentclass[twocolumn]{article}
\usepackage{amsmath}
%%% the pure symbol, see https://tex.stackexchange.com/a/718194/4427
\newcommand{\cind}{\perp\mspace{-9mu}\perp}
%%% define \indep
\NewDocumentCommand{\indep}{e{_}}{%
\mathrel{%
\IfNoValueTF{#1}{% no subscript
\cind
}{% subscript
\mathchoice{\mathop{\cind}\limits_{#1}}{\cind_{#1}}{\cind_{#1}}{\cind_{#1}}%
}%
}%
}
\begin{document}
$a \indep b$
$a \indep_{C} b$
\[
a \indep_{C} b
\]
\end{document}
The option twocolumn
has been used just to get a smaller picture.
Avoid $$
in LaTeX.
For a taller symbol (but a bit lowered under the baseline):
\documentclass[twocolumn]{article}
\usepackage{amsmath}
%%% the pure symbol
\makeatletter
\newcommand{\longperp}{\mathpalette\longperp@\relax}
\newcommand{\longperp@}[2]{%
\raisebox{-0.15\height}{%
\ooalign{\hidewidth\raisebox{\depth}{$\m@th#1\vert$}\hidewidth\cr$\m@th#1\perp$\cr}%
}%
}
\newcommand{\cind}{{\longperp\mspace{-9mu}\longperp}}
%%% define \indep
\NewDocumentCommand{\indep}{e{_}}{%
\mathrel{%
\IfNoValueTF{#1}{% no subscript
\cind
}{% subscript
\mathchoice{\mathop{\cind}\limits_{#1}}{\cind_{#1}}{\cind_{#1}}{\cind_{#1}}%
}%
}%
}
\begin{document}
$A \indep B$
$a \indep_{C} b$
\[
a \indep_{C} b
\]
\end{document}
A not so taller version:
\documentclass[twocolumn]{article}
\usepackage{amsmath}
\usepackage{graphicx}
%%% the pure symbol
\makeatletter
\newcommand{\longperp}{\mathpalette\longperp@\relax}
\newcommand{\longperp@}[2]{%
\ooalign{%
\hidewidth\raisebox{\depth}{\scalebox{1}[0.8]{$\m@th#1\vert$}}\hidewidth\cr
$\m@th#1\perp$\cr
}%
}
\newcommand{\cind}{\longperp\mspace{-9mu}{\longperp}}
%%% define \indep
\NewDocumentCommand{\indep}{e{_}}{%
\mathrel{%
\IfNoValueTF{#1}{% no subscript
\cind
}{% subscript
\mathchoice{\mathop{\cind}\limits_{#1}}{\cind^{}_{#1}}{\cind_{#1}}{\cind_{#1}}%
}%
}%
}
\begin{document}
$\indep\perp$
$A \indep B$
$a \indep_{C} b$
$\displaystyle % emulate \[...\]
a \indep_{C} b
$
\end{document}
-
Thanks! It was very useful. Some two question: why should I avoid $$? and i'm sorry to be nitpicky but... is there a way of making it taller? it looks nice, but I'm relating probabilistic independence with independence by non-forking, and this symbol looks way shorter in comparison Commented Jun 4 at 13:40
-
@SusanaSantoyo - For your first question, please see the posting Why is
\[ ... \]
preferable to$$ ... $$
?– MicoCommented Jun 4 at 18:00 -
-
There is the built-in \coprod
symbol:
\documentclass{article}
\begin{document}
$a\coprod b\quad a\coprod_c b\quad{\displaystyle a\coprod_c b}$
\end{document}
Alternatively, you can make a double \perp
symbol:
Adjust the \mkern
length to your liking.
\documentclass{article}
\usepackage{amsmath, scalerel}
\DeclareMathOperator*{\indep}{\scalerel*{\perp\mkern-9mu\perp}{\sum}}
\begin{document}
$a\indep b\quad a\indep_c b\quad{\displaystyle a\indep_c b}$
\end{document}