I am trying to write the following mathematical expression in latex:
Can anybody help me out about how can I write this in latex?
I am trying to write the following mathematical expression in latex:
Can anybody help me out about how can I write this in latex?
This code:
\documentclass[border=15]{standalone}
\usepackage{amsmath}
\begin{document}
$z_1, \ldots, z_n \stackrel{\mathrm{i.i.d.}}{\sim} N(0, \sigma^2)$
\end{document}
produces exactly what is in your figure.
Another solution:
\documentclass{standalone}
\newcommand{\iid}{\mathbin{\ooalign{\hidewidth\raise1.2ex\hbox{\tiny i.i.d}\hidewidth\cr$\sim$\cr}}}
\begin{document}
$ z_1, \dots, z_n \iid N(0, \sigma^2) $
\end{document}
which produces
but I think I prefer it without the dots:
\documentclass{standalone}
\newcommand{\iid}{\mathbin{\ooalign{\hidewidth\raise1.2ex\hbox{\tiny iid}\hidewidth\cr$\sim$\cr}}}
\begin{document}
$ z_1, \dots, z_n \iid N(0, \sigma^2) $
\end{document}
For details of ooalign see this highly rated answer.
Plain TeX uses macro \buildrel for such purposes:
$ z_1, \dots, z_n \buildrel\rm iid \over\sim N(0, \sigma^2) $
\bye