In this chapter, we explore the issue of encoding, recognizing, generalizing and reproducing arbitrary gestures. We address one major and generic issue, namely how to discover the essence of a gesture, i.e. how to find a representation of the data that encapsulates only the key aspects of the gesture, and discards the intrinsic variability across people motions. The model is tested and validated in a humanoid robot, using kinematics data of human motion. In order for the robot to learn new skills by imitation, it must be endowed with the ability to generalize over multiple demonstrations. To achieve this, the robot must encode multivariate time-dependent data in an efficient way. Principal Component Analysis and Hidden Markov Models are used to reduce the dimensionality of the dataset and to extract the primitives of the motion. The model takes inspiration in a recent trend of research that aims at defining a formal mathematical framework for imitation learning. In particular, it stresses the fact that the observed elements of a demonstration, and the organization of these elements should be stochastically described to have a robust robotic application. It bears similarities with theoretical models of animal imitation, and offers at the same time a probabilistic description of the data, more suitable for a real-world application.