I am trying to generate a tikz figure similar to

So far I made the following latex code:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
pics/BitArray/.style n args={2}{
code={\begin{scope}[#2]
\fill
\foreach \row [count=\y] in {#1} {
\foreach \cell [count=\x] in \row {
\ifnum\cell=1 %
(\x-1, -\y+1) rectangle ++(1, -1)
\fi
\pgfextra{%
\global\let\maxx\x
\global\let\maxy\y
}%
}
}
;
\draw[thin] (0, 0) grid[step=1] (\maxx, -\maxy);
\end{scope}
}
}
}
\begin{document}
\[
\begin{tikzpicture}[scale=5]
[baseline=(N.base)]
\begin{scope}[local bounding box=BA1,scale=0.4]
\foreach \y in {0.2,0.4,...,1.8} {
\foreach \x in {0.2,0.4,...,1.2} {
\pgfmathparse{0.9*rnd+0.01}
\definecolor{MyColor}{rgb}{\pgfmathresult,\pgfmathresult,\pgfmathresult}
\node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (\x,\y) {};
}
}
\draw[step=.2,help lines] (0,0) grid (1.4,2);
\end{scope}
\node[above=1pt of BA1] {$D$};
\node[left=1pt of BA1.north west] {$X$};
\node[left=1pt of BA1.west] (N) {$N$};
\end{tikzpicture}
~\sim~
\begin{tikzpicture}[baseline=(N2.base)]
\begin{scope}[local bounding box=BA2,scale=0.5]
\pic[right=3cm of BA1.north east] {BitArray={%
{1,1,1,1},
{1,1,1,0},
{1,0,1,1},
{1,0,0,1},
{1,1,0,0},
{0,1,0,1},
{0,0,1,0},
{0,1,0,0},
{0,0,0,0},
{0,0,0,0}%
}{fill=black,scale=0.5}};
\end{scope}
\node[left=1pt of BA2.north west] {$\mathbf{Z}$};
\node[above=1pt of BA2] {$K$};
\node[left=1pt of BA2.west] (N2) {$N$};
\end{tikzpicture}
~\dots~*
\begin{tikzpicture}[scale=5][baseline=(dots.base)]
\begin{scope}[local bounding box=BA3,scale=0.4]
\foreach \y in {0.2,0.4,...,0.6} {
\foreach \x in {0.2,0.4,...,1.2} {
\pgfmathparse{0.9*rnd+0.01}
\definecolor{MyColor}{rgb}{\pgfmathresult,\pgfmathresult,\pgfmathresult}
\node[fill=MyColor,inner sep=0.4cm,outer sep=0pt,anchor=center] at (\x,\y) {};
}
}
\draw[step=.2,help lines] (0,0) grid (1.4,0.8);
\end{scope}
\node[below=1pt of BA3.south] (dots) {$\vdots$};
\end{tikzpicture}
\]
\end{document}
Any suggestion how to complete my figure?
Second question: How can I make for instance a gamma distribution just using tikz? Is it possible?
