<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ancestral_states(self, n):
 """ Generate ancestral sequence states from the equilibrium frequencies """

        anc = np.empty(n, dtype=np.intc)
        _weighted_choices(self.state_indices, self.freqs, anc)
        return anc