A $theta$ term in lattice field theory causes the sign problem in Monte Carlo simulations. This problem can be circumvented by Fourier-transforming the topological charge distribution $P(Q)$. This strategy, however, has a limitation, because errors of $P(Q)$ prevent one from calculating the partition function ${cal Z}(theta)$ properly for large volumes. This is called flattening. As an alternative approach to the Fourier method, we utilize the maximum entropy method (MEM) to calculate ${cal Z}(theta)$. We apply the MEM to Monte Carlo data of the CP$^3$ model. It is found that in the non-flattening case, the result of the MEM agrees with that of the Fourier transform, while in the flattening case, the MEM gives smooth ${cal Z}(theta)$.