Folland Exercise 3.17 
Let $(X, \mathcal M, \mu)$ be a finite measure space, $\mathcal N$ a sub-$\sigma$-algebra of $\mathcal M$, and $\nu = \mu|\mathcal N$.  If $f \in L^1(\mu)$, there exists $g \in L^1(\nu)$ (thus $g$ is $\mathcal N$-measurable) such that $\int_E f d\mu = \int_E g d\nu$ for all $E \in \mathcal N$; if $g'$ is another such function then $g = g'$ $\nu$-a.e.  (In probability theory, $g$ is called the conditional expectation of $f$ on $\scr{N}$.)

I have managed to prove this statement to be true by defining a measure $\lambda$ such that $d\lambda = gd\nu$ and then using Lebesgue-Radon-Nikodym theorem. Now as an extension of the problem, I want to characterize $g$ in terms of $f$ when $\mathcal N = \{\emptyset, X\}$, and when $\mathcal N=\{\emptyset, X, E, E^c\}$ for some $E\in\mathcal M$. Now I'm not sure how to do the last bit, and completely stuck here. 
I would like to get some help on how to tackle the last part.
 A: When $\mathcal{N} = \{\emptyset,X\}$, you can check that
$$g = \left( \frac{1}{\mu(X)}\int_X f \, d\mu \right)  \mathbb{I}_X$$ (i.e., a constant function) does the job.
When $\mathcal{N} = \{\emptyset,E,E^c,X\}$, 
$$g = \left(  \frac{1}{\mu(E)}\int_E f \, d\mu \right)  \mathbb{I}_E + \left(  \frac{1}{\mu(E^c)}\int_{E^c} f \, d\mu \right)  \mathbb{I}_{E^c}$$
does the same thing.
To understand the construction we can think of a concrete example which parallels your problem: let's say you are a video game designer building a virtual world with 7 billion humans. You want them to approximate real-world humans in terms of their physical heights. The absolute best you could do is to match every human in the world to a video game human and make their heights correspond (this corresponds to taking $\mathcal{N}=\mathcal{M})$. The worst you could do is to make every video game human the same height, with that height being the average real human height (what else would it be?)  A slight improvement is to divide the virtual humans into male and female, then make all females have the average real female height, and all males have the average real male height. These last two cases correspond to your question.
By the way, to make sure you understand the construction you should try it for the case when $\mathcal{N}$ is generated by a countable partition of $X$ (i.e. when $X = \sqcup E_i$ for $E_i$ measurable).
