Abstract—Conventionally, automatic music composition is done by evolving music sequences whose fitness is evaluated by a human listener. This interactive approach has led to interesting results but is very time consuming. Here we propose a system that is capable of automatically generating music using an evolutionary algorithm (EA), replacing the human evaluation process with a trainable music evaluation algorithm. This algorithm can be trained on existing music samples, such as Mozart compositions for example. This kind of system could provide a fast and cheap music composition tool. The current evaluation system is implemented with an N-gram language model. This paper discusses the system in two parts. Firstly, it describes the performance of the proposed music evaluation algorithm. Secondly, it discusses the impacts of different sequence-oriented genetic operators in the evolutionary algorithm. Part one of the experimental results show that the N-Gram model is able to distinguish the composer of piano compositions by Mozart, Beethoven and Chopin with up to 81.9% accuracy. Part two of the results show that some of the sequence-oriented operators increased the fitness of the generated melodies, but some operators did not. The impacts of these operators are discussed in the experimental results section. Significantly, the results also show that better classification accuracy does not necessarily lead to better evolved music, suggesting that perceptual relevance is also an important factor. I. INTRODUCTION LGORITHMIC music composition is an important topic in music technology. It could be described as a set of well-defined rules of music composition. The idea of algorithmic composition is not new. Researchers Hiller and Isaacson [8] were possibly the first to study this field scientifically. They based their research on Markov Chains. Since then many researchers have attempted to address different problems of algorithmic composition. The later developments of algorithmic composition can be divided into stochastic and deterministic. Mozart’s dice game [2] is an example that used a stochastic technique. This game uses a dice roll as a random generator to select prewritten bar music and these were combined to form full length music compositions. All prewritten bars were composed such that every bar harmonises with every other one, hence, the resulting music satisfies certain musical requirements. Deterministic systems often pre-define all the rules, with the output then depending only on the particular inputs used to drive the generator (as opposed to some stochastic element). The Fibonacci sequence [4] and L-systems [16] are examples of a deterministic technique. The main objectives of this research are to investigate the capability of N-grams to act as the music fitness function in an evolutionary algorithm, and to investigate the effectiveness of different sequence-oriented variation operators for this task. II. BACKGROUND KNOWLEDGE AND LITERATURE REVIEW A. N-grams In the field of Natural Language Processing, N-grams are a widely used statistical language modelling technique, a type of Markov Model (MM). This technique is based on the assumption that the next symbol in a string is largely dependent on a small number of immediately preceding symbols in the string. N is a model parameter which represents the total number of preceding symbols plus the current symbol. N could be any number >= 1. E.g. N=1 is called a Uni-gram which looks zero (N-1) symbols into the past. N=2 is called a Bi-gram which looks only one symbol into the past. N=3 is called Tri-gram which looks two symbols into the past. Despite (alternatively, because of) their simple nature, N-grams work well in practice, providing sufficiently large samples of training data are available. N- grams have been mostly used in text prediction, text retrieval and pattern recognition [9]. Recently, researcher Doraisamy [5] used N-gram for music indexing in a large music database which contains polyphonic music in MIDI format. Statistical methods tend to be more robust in learning from data samples than purely symbolic techniques. Generally working with N-grams, user chooses N preceding symbols that the next symbol is assumed to depend on. Equation (1) is the equation for a Bi-gram model (N=2); this generalises in straightforward ways to different values of N. n w : Individual symbol n w , where n is it order. 1 - n w : Previous symbol to n w . n w w w w ..., , , 3 2 1 Or n w 1 : Representing the complete string (sequence) of symbols. ) ( 1 n w P : The probability of complete string. ) ( 1 n w P = = - n k k k w w P w P 2 1 1 ) | ( ) ( (1) Evolving Musical Sequences with N-Gram Based Trainable Fitness Functions ManYat Lo, Simon M. Lucas, University of Essex, UK A