Measure Theory - Building Intuition I'm new in this world, so I apologize if this question is missing information.
Let $\Omega = \{\text{all students in the classroom}\}$.
Let $X(\omega) = 0$, if $\omega$ male student, and $X(\omega) = 1$, if $\omega$ is a female student.
Then $\sigma(X)$ consists of 4 subsets. Which ones? 
 A: If $X$ is a random variable then in general: $$\sigma(X)=\{\{X\in B\}\mid B\in\mathcal B\}$$
where $\mathcal B$ denotes the Borel $\sigma$-algebra on $\mathbb R$ and: $$\{X\in B\}:=X^{-1}(B)=\{\omega\in\Omega\mid X(\omega)\in B\}$$
In your case $X$ can only take values in $\{0,1\}$ and consequently the set $\{X\in B\}$ can only take $4$ forms:


*

*$\varnothing$ if $B\cap\{0,1\}=\varnothing$

*$\{\text{male students}\}$ if $B\cap\{0,1\}=\{0\}$

*$\{\text{female students}\}$ if $B\cap\{0,1\}=\{1\}$

*$\Omega=\{\text{all students}\}$ if $B\cap\{0,1\}=\{0,1\}$


So we end up with:$$\sigma(X)=\{\varnothing,\{\text{male students}\},\{\text{female students}\},\Omega\}$$
A: The $\sigma$-algebra generated by a random variable $X$ in the probability space $(\Omega, \mathscr F, \mathbb P)$ is all the preimages of $X$ for any Borel set. What does this mean?
For any Borel set $B$ (pretend I said 'any subset' for the sake of understanding but then accept that any subset will technically not work) in the real numbers, there exists a subset of the sample space $\Omega$ that is also in $\mathscr F$, i.e., its $\mathbb P$robability can be computed s.t. if the subset is inputted into $X$, $X$ will give an output that is all the values in the Range of $X$ that is in $B$.
This is given by
$$\sigma(X)=\{ X^{-1}(B) | B\in\mathscr B\}$$
where $X^{-1}(B)$ is the said subset for a given $B$. This is given by
$$X^{-1}(B)=\{\omega\in\Omega | X(\omega)\in B\}.$$
Note that
$$X^{-1}(B) \in \mathscr F$$
$$X^{-1}(B) \subseteq \Omega$$
$$B \in \mathscr B$$
$$B \subseteq \mathbb R$$
Here, $X$ is an indicator/characteristic function for females: If you input a female student, $X$ gives you 1 and 0 otherwise (I assume all students are male xor female). This is given by
$$X(\text{(any) female student in the classroom}) = 1$$
$$X(\text{(any) male student in the classroom}) = 0$$
On the other hand, an output of 1 lets you know you've got female, and 0 lets you know you've got male. This is given by
$$X^{-1}(\{1\}) = \{\omega \in \Omega | X(\omega) = 1 \} = \{\omega \in \Omega | \omega \text{ is a female student in the classroom} \} = \{\text{(all) female students in the classroom}\}$$
$$X^{-1}(\{0\}) = \{\omega \in \Omega | X(\omega) = 0 \} = \{\omega \in \Omega | \omega \text{ is a male student in the classroom} \} = \{\text{(all) male students in the classroom}\}$$
However, we need not be limited by singletons. We can use intervals, unions of disjoint intervals, etc. For example,
$$X^{-1}((0.5,1.5] \cup {2} = \{\omega \in \Omega | X(\omega) \in (0.5,1.5]  \cup {2} \} = \{\omega \in \Omega | X(\omega) = 1 \} = \{\omega \in \Omega | \omega \text{ is a female student in the classroom} \} = \{\text{female students in the classroom}\}$$
$X$ doesn't care about the numbers in $(0.5,1.5] \cup {2}$ besides $1$ because its range consists only $0$ and $1$, i.e. $Range(X) = \{0,1\}$. Other examples:
$$X^{-1}((\pi,2,000]) = \{\omega \in \Omega | X(\omega) \in (\pi,2,000] \} = \{\omega \in \Omega | X(\omega) \in \emptyset^{\mathbb R} \}$$
$$= \{\omega \in \Omega | \omega \text{ is neither male nor female student in the classroom} \} = \emptyset^{\Omega}$$
$$X^{-1}([0,10]) = \{\omega \in \Omega | X(\omega) \in [0,10] \} = \{\omega \in \Omega | X(\omega) \in \{0,1\} \}$$
$$= \{\omega \in \Omega | \omega \text{ is a male or female student in the classroom} \} = \Omega$$
$$X^{-1}([-1,1)) = \{\omega \in \Omega | X(\omega) \in [-1,1) \} = \{\omega \in \Omega | \omega \text{ is a male student in the classroom} \} = \{\text{male students in the classroom}\}$$
Now, we can use any Borel set $B$. The important thing is whether or not $B$ has any 0's or 1's. Here's what to do:
$$X^{-1}(B) = \{\omega \in \Omega | X(\omega) \in B \} = \{\omega \in \Omega | \omega \text{'s that satisfy the condition} \} = \text{subset of} \ \Omega \ \text{that is in} \ \mathscr F \}$$
In your case I guess $\Omega$ would be finite, and all its subsets are in $\mathscr F$. Anyway, 4 cases


*

*$B$ has $1$ but not $0$


$$X^{-1}(B) = \{\omega \in \Omega | X(\omega) \in B \} = \{\omega \in \Omega | X(\omega) = 1 \} = \{\omega \in \Omega | \omega \text{ is a female student in the classroom} \} = \{\text{female students in the classroom}\}$$


*$B$ has neither $1$ nor $0$


$$X^{-1}(B) = \{\omega \in \Omega | X(\omega) \in B \} = \{\omega \in \Omega | X(\omega) \in \emptyset^{\mathbb R} \}$$
$$= \{\omega \in \Omega | \omega \text{ is neither male nor female student  in the classroom} \} = \emptyset^{\Omega}$$


*$B$ has both $1$ and $0$


$$X^{-1}(B) = \{\omega \in \Omega | X(\omega) \in B \} = \{\omega \in \Omega | X(\omega) \in \{0,1\} \}$$
$$= \{\omega \in \Omega | \omega \text{ is a male or female student in the classroom} \} = \Omega$$


*$B$ has $0$ but not $1$


$$X^{-1}(B) = \{\omega \in \Omega | X(\omega) \in B \} = \{\omega \in \Omega | \omega \text{ is a male student in the classroom} \} = \{\text{male students in the classroom}\}$$
Thus, 
$X^{-1}(B) = $


*

*$\{\text{female students in the classroom}\}$ if $B$ has $1$ but not $0$

*$\emptyset^{\Omega}$ if $B$ has neither $1$ nor $0$

*$\Omega$ if $B$ has both $1$ and $0$

*$\{\text{male students in the classroom}\}$ if $B$ has $0$ but not $1$


Since $B$ cannot have other forms according to whether or not $B$ has $0$ or $1$, the cases are exhaustive. Thus, we know that $X^{-1}(B)$ cannot take any other forms.
Therefore:
$$\sigma(X)=\{ X^{-1}(B) | B\in\mathscr B\} = \{\emptyset^{\Omega},\{\text{male students in the classroom}\},\{\text{female students in the classroom}\},\Omega\}$$
