\begin{tikzpicture}[scale=1]
% Draw the 8x8 grid
\begin{scope}
    
\node[anchor=south] at (2,4.25) {$X_2$};
\begin{scope}[scale=0.5]

\draw[thin, myblack!70] (0,0) grid (8,8);

% Define random points (not crossing grid cell borders)
% Each point is placed within a grid cell with a small margin
\coordinate (p1) at (0.3,0.7);
\coordinate (p2) at (0.6,7.4);
\coordinate (p3) at (1.3,1.6);
\coordinate (p4) at (1.7,4.3);
\coordinate (p5) at (1.8,6.2);
\coordinate (p6) at (2.4,0.6);
\coordinate (p7) at (2.7,3.3);
\coordinate (p8) at (2.8,5.7);
\coordinate (p9) at (3.2,2.4);
\coordinate (p10) at (3.6,7.3);
\coordinate (p11) at (4.3,0.4);
\coordinate (p12) at (4.7,3.7);
\coordinate (p13) at (4.8,6.8);
\coordinate (p14) at (5.3,1.3);
\coordinate (p15) at (5.6,4.6);
\coordinate (p16) at (5.7,7.2);
\coordinate (p17) at (6.4,2.7);
\coordinate (p18) at (6.6,5.4);
\coordinate (p19) at (7.3,0.8);
\coordinate (p20) at (7.7,3.2);
\coordinate (p21) at (7.8,6.5);
\coordinate (p22) at (2.5,1.6);
% Draw all points
\foreach \i in {1,...,22} {
  \fill (p\i) circle (0.1);
}

% Color 2x2 regions based on pmyredetermined point counts
% Bottom left (0,0) to (2,2) - 3 points
\fill[myred, opacity=0.5] (0,0) rectangle (2,2);
\draw[thick] (0,0) rectangle (2,2);

% Bottom middle left (2,0) to (4,2) - 2 points
\fill[myred, opacity=0.5] (2,0) rectangle (4,2);
\draw[thick] (2,0) rectangle (4,2);

% Bottom middle right (4,0) to (6,2) - 2 points
\fill[myred, opacity=0.5] (4,0) rectangle (6,2);
\draw[thick] (4,0) rectangle (6,2);

% Bottom right (6,0) to (8,2) - 1 point
\fill[myblue, opacity=0.5] (6,0) rectangle (8,2);
\draw[thick] (6,0) rectangle (8,2);

% Middle bottom left (0,2) to (2,4) - 1 point
\fill[opacity=0.5] (0,2) rectangle (2,4);
\draw[thick] (0,2) rectangle (2,4);

% Middle center left (2,2) to (4,4) - 2 points
\fill[myred, opacity=0.5] (2,2) rectangle (4,4);
\draw[thick] (2,2) rectangle (4,4);

% Middle center right (4,2) to (6,4) - 2 points
\fill[myblue, opacity=0.5] (4,2) rectangle (6,4);
\draw[thick] (4,2) rectangle (6,4);

% Middle right (6,2) to (8,4) - 2 points
\fill[myred, opacity=0.5] (6,2) rectangle (8,4);
\draw[thick] (6,2) rectangle (8,4);

% Middle top left (0,4) to (2,6) - 1 point
\fill[myblue, opacity=0.5] (0,4) rectangle (2,6);
\draw[thick] (0,4) rectangle (2,6);

% Middle top center left (2,4) to (4,6) - 1 point
\fill[myblue, opacity=0.5] (2,4) rectangle (4,6);
\draw[thick] (2,4) rectangle (4,6);

% Middle top center right (4,4) to (6,6) - 1 point
\fill[myblue, opacity=0.5] (4,4) rectangle (6,6);
\draw[thick] (4,4) rectangle (6,6);

% Middle top right (6,4) to (8,6) - 1 point
\fill[myblue, opacity=0.5] (6,4) rectangle (8,6);
\draw[thick] (6,4) rectangle (8,6);

% Top left (0,6) to (2,8) - 2 points
\fill[myred, opacity=0.5] (0,6) rectangle (2,8);
\draw[thick] (0,6) rectangle (2,8);

% Top center left (2,6) to (4,8) - 2 points
\fill[myblue, opacity=0.5] (2,6) rectangle (4,8);
\draw[thick] (2,6) rectangle (4,8);

% Top center right (4,6) to (6,8) - 2 points
\fill[myred, opacity=0.5] (4,6) rectangle (6,8);
\draw[thick] (4,6) rectangle (6,8);

% Top right (6,6) to (8,8) - 1 point
\fill[myblue, opacity=0.5] (6,6) rectangle (8,8);
\draw[thick] (6,6) rectangle (8,8);
\end{scope}
% Add a legend
\fill[myblue, opacity=0.5] (0.25,-0.75) rectangle (0.75,-0.25);
\draw (0.25,-0.75) rectangle (0.75,-0.25);
\node[anchor=north] at (1.5, -0.25) {$X_{1,0}$};

\fill[myred, opacity=0.5] (2.25,-0.75) rectangle (2.75,-0.25);
\draw (2.25,-0.75) rectangle (2.75,-0.25);
\node[anchor=north] at (3.5,-0.25) {$X_{1,1}$};

\node[anchor=north] at (2,-1) {$\mu(X_{2,0}) = 8$, $\mu(X_{2,1}) = 14$};

\end{scope}
\begin{scope}[xshift=6cm]
    
\node[anchor=south] at (2,4.25) {$X_1$};
\begin{scope}[scale=0.5]

\draw[thin, myblack!70] (0,0) grid (8,8);

% Define random points (not crossing grid cell borders)
% Each point is placed within a grid cell with a small margin
\coordinate (p1) at (0.3,0.7);
\coordinate (p2) at (0.6,7.4);
\coordinate (p3) at (1.3,1.6);
\coordinate (p5) at (1.8,6.2);
\coordinate (p6) at (2.4,0.6);
\coordinate (p7) at (2.7,3.3);
\coordinate (p9) at (3.2,2.4);
\coordinate (p11) at (4.3,0.4);
\coordinate (p13) at (4.8,6.8);
\coordinate (p14) at (5.3,1.3);
\coordinate (p16) at (5.7,7.2);
\coordinate (p17) at (6.4,2.7);
\coordinate (p20) at (7.7,3.2);
\coordinate (p22) at (2.5,1.6);

% Draw 4x4 grid cell squares with appropriate colors
% Bottom-left 4x4 square (0,0) to (4,4)
% Contains points p1, p3, p6, p7, p9, p22 = 6 points
\fill[myred, opacity=0.5] (0,0) rectangle (4,4);
\draw[thick] (0,0) rectangle (4,4);

% Bottom-right 4x4 square (4,0) to (8,4)
% Contains points p11, p14, p17, p20 = 4 points
\fill[myred, opacity=0.5] (4,0) rectangle (8,4);
\draw[thick] (4,0) rectangle (8,4);

% Top-left 4x4 square (0,4) to (4,8)
% Contains points p2, p5 = 2 points
\fill[myblue, opacity=0.5] (0,4) rectangle (4,8);
\draw[thick] (0,4) rectangle (4,8);

% Top-right 4x4 square (4,4) to (8,8)
% Contains points p13, p16 = 2 points
\fill[myblue, opacity=0.5] (4,4) rectangle (8,8);
\draw[thick] (4,4) rectangle (8,8);

% Draw all points
\foreach \i in {1,2,3,5,6,7,9,11,13,14,16,17,20,22} {
  \fill (p\i) circle (0.1);
}

\end{scope}
% Add a legend
\fill[myblue, opacity=0.5] (0.25,-0.75) rectangle (0.75,-0.25);
\draw (0.25,-0.75) rectangle (0.75,-0.25);
\node[anchor=north] at (1.5, -0.25) {$X_{0,0}$};

\fill[myred, opacity=0.5] (2.25,-0.75) rectangle (2.75,-0.25);
\draw (2.25,-0.75) rectangle (2.75,-0.25);
\node[anchor=north] at (3.5,-0.25) {$X_{0,1}$};

\node[anchor=north] at (2,-1) {$\mu(X_{0,0}) = 4$, $\mu(X_{0,1}) = 10$};

\end{scope}
\begin{scope}[xshift=3cm, yshift=-6.5cm]
    
\node[anchor=south] at (2,4.25) {$X_0$};
\begin{scope}[scale=0.5]

\draw[thin, myblack!40] (0,0) grid (8,8);
\draw[thick] (0,0) rectangle (8,8);

% Define random points (not crossing grid cell borders)
% Each point is placed within a grid cell with a small margin
\coordinate (p6) at (2.4,0.6);
\coordinate (p7) at (2.7,3.3);
\coordinate (p9) at (3.2,2.4);
\coordinate (p11) at (4.3,0.4);
\coordinate (p14) at (5.3,1.3);
\coordinate (p17) at (6.4,2.7);
\coordinate (p20) at (7.7,3.2);
\coordinate (p22) at (2.5,1.6);

% Draw 4x4 grid cell squares with appropriate colors


% Draw all points
\foreach \i in {1,2,3,5,6,7,9,11,13,14,16,17,20,22} {
  \fill (p\i) circle (0.1);
}

\end{scope}


\end{scope}

\end{tikzpicture}
