Dynamical analysis of a financial market with fundamentalists, chartists, and imitators