[Tex/LaTex] How to get a “approximately follows distribution” symbol

stacking-symbolssymbols

I want to create an "approximately follows distribution" symbol. It should be a \sim with one dot above and one below.

I have tried using \underset and \overset, but I cannot get the dots to be the same distance above and below \sim.

Thanks,

Jack

Best Answer

\documentclass{article}

\makeatletter
\newcommand\approxsim{\mathpalette\@approxsim\relax}
\newcommand\@approxsim[2]{%
  \mathrel{%
    \ooalign{%
      $\m@th#1\sim$\cr
      \hidewidth$\m@th#1:$\hidewidth\cr
    }%
  }%
}
\makeatother

\begin{document}

$a \approxsim b_{a \approxsim b_{a \approxsim b}}$

\end{document}

enter image description here

This is maybe a bit nicer.

\documentclass{article}

\makeatletter
\newcommand\approxsim{\mathchoice
  {\@approxsim {\displaystyle}      {1ex} }
  {\@approxsim {\textstyle}         {1ex} }
  {\@approxsim {\scriptstyle}       {.7ex}}
  {\@approxsim {\scriptscriptstyle} {.5ex}}}
\newcommand\@approxsim[2]{%
  \mathrel{%
    \ooalign{%
      $\m@th#1\sim$\cr
      \hidewidth$\m@th#1.$\hidewidth\cr
      \hidewidth\raise #2 \hbox{$\m@th#1.$}\hidewidth\cr
    }%
  }%
}
\makeatother

\begin{document}

$a \approxsim b_{a \approxsim b_{a \approxsim b}}$

\end{document}

enter image description here