I'd like to create the following plot (illustrating a population and a random sample) with tikz where the dots are created/placed randomly; all dots inside the circle, however, are supposed to be coloured in red:
Using answers based on previous (somewhat similar) questions, I was able to create the following plot.
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- cycle;
\foreach \x in {1,...,40}
{
\pgfmathrandominteger{\a}{10}{390}
\pgfmathrandominteger{\b}{10}{390}
\fill (\a*0.01,\b*0.01) circle (0.1);
};
\draw (2,2) circle (1cm);
\end{tikzpicture}
\end{document}
However, I have no clue how to color the dots inside the circle in red (I have a vague idea that involves basic geometry and ifelse by checking every dot if it is placed inside the circle... does that make sense?).