International Journal of Advanced Science, Engineering and Technology. ISSN 2319-5924 Vol 1, Issue 1, 2012, pp 29-38 http://www.bipublication.com

ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN THROUGH AN ARIMA MODEL

1* Soubhik Chakraborty, 2Ripunjai Kumar Shukla, 3Kartik Mahto, 4Sandeep Singh Solanki, 5Shivee Chauhan, 6Loveleen and 7Kolla Krishnapriya

1,2 Department of Applied Mathematics. BIT Mesra, Ranchi-835215, India 3-7Department of Electronics and Communication Engineering, BIT Mesra, Ranchi-835215, India *corresponding author’s email: [email protected] (S. Chakraborty)

[Received-22/08/2012, Accepted-09/10/2012]

ABSTRACT Time series is a series of observations in chronological order. The argument or predictor is time which may or may not be the time of clock, i.e. , it could well be simply the instance represented by indices 1, 2, 3…which is certainly true for a sequence of notes in a raga depicting its melodic structure with some musical sense of completeness. The dependent variable is the pitch characterizing the note. The present study shows how an ARIMA model can effectively analyze the melodic structure of a North Indian raga . While the model itself is reserved for prediction, the lag of unity in the model also suggests a Markov chain of order one which can then be used to simulate the raga sequence on a computer. In this way our study supports both prediction and composition .

Keywords: Time series; ARIMA model, raga; melodic structure; Markov chain; transition probability matrix

1. INTRODUCTION modeling. Another advantage is that for A raga is a melodic structure with fixed notes performance data, the argument would yield and a set of rules characterizing a certain mood unequal spaced onsets (actual point of arrival) conveyed by performance. However, we can of notes complicating the analysis. Before also statistically analyze the melodic structure describing the modeling, it is worth taking a of the raga without going into performance by look at some of the basic features of the North considering a sequence of notes that capture the Indian raga Multani, which we shall analyze emotion of the raga in some sense of here . completeness as given by Indian music theory. • Raga: Multani [Dutta(2006)] The advantage of this study is that it is fairly : (Thaat is a kind of grouping of according to the specific notes used) general and does not depend on any specific Aroh (ascent): N S, g m P, N S artist. Thus our conclusion would also be fairly Awaroh(descent) : S N d Pm g r S general giving an overview of the raga from a Jati(another grouping of raga reflecting no. of theoretical angle with special emphasis on distinct notes used in ascent-descent): Aurabh- ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

Sampoorna (5 distinct notes used in ascent, 7 in Todi and Multani in matters concerning g is descent) suggested in the next tonal strip. Vadi Swar (most important note): P Samvadi Swar (second most important note): S N S (m)g m P, m P (m)g, m g (S)r(N)S Prakriti (nature): restful Characteristic of Multani is the Arohi (catch): N S, m g, P g, r S ucchAraNa of g: it is tugged with m as in (m)g Nyas swars (Stay notes): S g P (m)g m P. Since g is approached from m, it has Time of rendition: 3 PM to 6 PM ABBREVIATIONS:- the effect of raising the shruti of g to a location The letters S, R, G, M, P, D and N stand for Sa above its nominal komal value. This in turn (always Sudh), Sudh Re, Sudh Ga, Sudh Ma, elevates the shruti of r. These microtonal Pa (always Sudh), Sudh Dha and Sudh Ni nuances are later demonstrated tellingly by respectively. The letters r, g, m, d, n represent Pandit Ramashreya Jha "Ramrang." The teevra Komal Re, Komal Ga, Tibra Ma, Komal Dha madhyam in Multani is very close to the and Komal Ni respectively. pancham, in the latter's penumbra, as it were. A note in Normal type indicates that it belongs P, ( m)g P, P (P)d(m)P, P (m)g, m g m g to middle octave; if in italics it is implied that (S)r(N)S the note belongs to the octave just lower than The treatment of d is congruent to that accorded the middle octave while a bold type indicates it r. The purNAvritti (repetition) of m g in belongs to the octave just higher than the avarohi prayogas is a point of note. As is the middle octave. Sa is the tonic in Indian music. langhan of m, occasionally from g to P and Here is Rajan P. Parrikar’s description of this more often through a meeND-laden avarohi P raga, reproduced with permission except for the to g. The importance of a powerful pancham to notation for octave which is ours Multani should be evident by now. (http://www.parrikar.org/raga-central/multani ). (m)g m P N, N, S, S g (S)r( N)S Parrikar is a recognized expert in Indian The uttarAnga launch proceeds thus, with a classical music. deergha N. The sharp m P N curve presents a “Multani is among the 'big' Ragas, highly source of discomfort to many a Khayal singer regarded by the afficionado of vocal music for especially in the faster passages; the tendency its weighty mien and wide melodic compass. to instead detour through m d N must be Although its basic swaric material is drawn checked. from the Todi thAT - S r g m P d N - it carries S, N S N d P, m P (m)g, m g m g (S)r(N)S no hint or trace of the Todi Raganga. Multani This sentence completes the overall avarohi picture.” has a highly evolved and independent swaroopa all its own. • See also Jairazbhoy (1971). Readers Let us examine the Raga lakshaNAs. To recap knowing Western music but new to Indian the notation convention: a swara enclosed in music are referred to a useful website by brackets represents a kaNa (grace) to the swara C.S. Jones immediately following it. (http://cnx.org/content/m12459/1.6/)

S, N S g (S)r(N)S We assume that the reader has a sound Both r and d are dropped in Arohi prayogas; the knowledge of statistics and is familiar with an avaroha is sampoorNa. The peculiar ARIMA model. So we move straight to the ucchAraNa (intonation) of r mediated by a statistical analysis. Details of the working of an kaNa (grace) of S is vital to Multani. Recall the ARIMA model have been, however, briefed in vastly different behavior of Todi in this region, appendix B. We have also done a melody with its deergha r and an intimate coupling with analysis of the structure of raga Multani using g. An inopportune nyAsa on r spells the kiss of statistics and the interested reader is referred to death for Multani. Further divergence between Chakraborty et. al. (2009).

2. Statistical Analysis

Soubhik Chakraborty, et al. 30 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

Taking the tonic Sa at C conventionally, the significant but failed in Ljung-Box test of twelve notes in the middle octave can be residuals independence. It also have the lower represented by the numbers 0 to 11 value of R 2 and greater value of MAE and respectively. MaxAPE (Maximum Absolute Percentage Sa of the next higher octave will be assigned error). In the context of ARIMA (1, 0, 0), this the number 12 etc while Ni (sudh) of the lower model have its AR coefficient significant, octave (before middle) is assigned the number - higher value of R 2 (58.3%) and lower value of 1 etc. RMSE (Root Mean Square Error), MAE, MaxAPE with successfully passing of residual assumption of independence. Finally it is observed that ARIMA (1, 0, 0) model is the best fitted model among the algebraic family of ARIMA because it fulfills all the selection criteria with independence of residuals. Identification

The sequence of notes in raga Multani depicting its melodic structure is taken from a standard text [Dutta (2006)]. This was coded with the help of above and is detailed in the appendix A. At the identification stage the correlogram of realization shows that acf in fig. 1(A) decrease very sharply revealed the presence of stationarity so there is no need to transform the data. However seasonality to some extent appeared in fig. 1 (A) but no statistical significance is there to having it Fig.-1(A) ACF under the consideration. Fig. 1 (B) indicates

that pacf cut-off at first lag and damping towards zero. Now the all model will be tentative model for the value p = 1, d = 0 and q =1. The tentative model will be ARIMA (1,0,0), ARIMA (0,0,1) and ARIMA (1,0,1). Table-1 Contains all the fitted tentative ARIMA model with its selection criterion. Among the Fitted ARIMA models ARIMA (1, 0, 1) model has its AR (Autoregressive) coefficient significant and MA (Moving average) coefficient non-significant with lower value of MAE (Mean Absolute Error), whereas ARIMA (0, 0, 1) model have its MA coefficient

Soubhik Chakraborty, et al. 31 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

Fig.-2(A)

Fig.-2(B)

Fig.-1(B) PACF

Fitting of Autoregressive Integrated model moving average Model

Fig.-3(A)

Soubhik Chakraborty, et al. 32 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

Table:1 Fitted ARIMA models

Fig.-4(A)

Fig.-3(B)

Fig.-4(B) 3. Utility of our study The fitted model is

Model AR MA CONST R2 RMSE MAE MaxAPE Ljunj-Box

ARIMA(1,0,0) 0.767* -- 3.911* 58.3 2.365 1.907 221.246 11.042 NS

ARIMA(0,0,1) -- -0.600* 4.021* 41.0 2.815 2.355 387.183 134.168*

ARIMA(1,0,1) 0.805* 0.092 NS 3.885* 58.5 2.365 1.901 241.197 11.828 NS

Yt = 3.911* + 0.767*Y t-1 + εi This equation satisfies all the criteria regarding the best fitted model. Since the lag is 1, we are motivated to compute the transition probability matrix of a first order Markov chain

Soubhik Chakraborty, et al. 33 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

[Wikipedia]. Deciding the order in a Markov note. The strategy is to generate a uniform chain is crucial as higher order need to be variate X in the range beneficial (Nierhaus, 2008). This means we are [0, 1] and, depending on whether X falls in [0, taking that the probability of the next note 7/28], [7/28, 14/28], [14,28, 16/28] or [16/28, depends on what the present note is. Thus the 28/28], the note at instance 2 is obtained as probability P(g/r) gives the probability that the either g, m, P or N with respective probabilities next note would be g given that the present note 7/28, 7/28, 2/28 and 12/28. If the note at is r. This is calculated by the number of times r instance 1 is other than Sa, use the has been followed by g divided by the number corresponding transition probability row as of times r has occurred in the entire sequence. given in table 3. However, in cases where the present note is S, Step 3: Using the note simulated at instance 2, since this is the last note in the sequence, the and using the corresponding transition probability P(r/S) for example would be probability row of this note, the next note at calculated by the number of times S has been instance 3 is simulated etc. followed by r divided by one subtracted from Caution: The octaves of the notes should be the number of times S has occurred. This is decided using Indian music theory. See also the because for the last occurrence of S, there is no next section. Notes No. of Occurrences infor Table 2: Overall Note distribution in RAGA MULTANI S 29 mati on r 15 of g 33 the m 46 next

P 46 trans ition d 19 , so N 21 the possibilities of a transition are one less than the number of occurrences of S. Table 3 gives the transition probability matrix of Multani Table 3: The Transition Probability Matrix of Raga sequence. Table 2 gives the overall note Multani: distribution. We emphasize here that the ARIMA model itself be reserved only for S r g m P d N prediction, while the transition probability matrix for the Markov chain of order one S 0 0 7/28 7/28 7/28 0 12/28

(validated by the lag of unity in the ARIMA r 1 0 0 0 0 0 0 0 model) be used to simulate compose a Multani g 0 15/33 0 7/33 11/33 0 sequence by running simulations on a 2/46 m 0 0 26/46 0 16/46 2/46 computer. In this way our study supports both 6/46 prediction and composition. The following P 1/46 0 0 29/46 1/46 9/46 0 0 algorithm is proposed to compose a Multani d 0 0 0 3/19 16/19 note sequence. 8/21 1/21 N 12/21 0 0 0 0 Step 1: Without any loss in generality, for example, take the note at instance 1 to be the 4. CONCLUSION tonic Sa. Critics often blame statisticians that their Step 2: Using the transition probabilities at Sa analysis only supports music prediction but not (see row one of table 3), one simulates the next music composition. For example, in a blog titled Limitations of Statistical Methods for

Soubhik Chakraborty, et al. 34 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

Analyzing Music [Dorrell (2005)], it is quite "A time series is a set of observations generated clearly stated “…In fact, it is safe to conclude sequentially in time. If the set is continuous, the that anyone who claims to have a good time series is said to be continous. If the set is predictive algorithm, but who does not have a discrete, the time series is said to be corresponding generative algorithm (i.e. an discrete.....in this book we consider only algorithm to compose music), probably has not discrete time series where observations are discovered the secret of what music is.” The made at a fixed interval".on page 2, they write use of a predictive ARIMA model of lag one "For example, in a sales forecasting validating a Markov chain of first order which problem....." indicating the response can also be in turn can effectively compose a raga sequence discrete! is thus valuable both from a statistical and a ARIMA madels are described on p.89 onwards musical perspective. One can certainly play in [1]. The three fundamental assumptions of such a simulated sequence in some instrument ARIMA madels do not include the fact that t such as a piano and thereby select other and Y(t) have to be continuous. The features like duration and loudness of the notes assumptions only say (1) there must be at least subjectively. The second part, like selection of 50 data points (2)the series is stationary and (3) octaves of the notes, should again be done the series is homoscedastic. And these can be using music theory. The result is a “semi- achieved both for discrete and continuous data. natural” composition that can arguably capture For these three fundamental assumptions, we the raga emotion better than an artificial refer the reader to chap. 4 of the web book of composition created exclusively by the regional science by Garrett and Leatherman computer. (http://www.rri.wvu.edu/WebBook/Garrett/cha As a final comment, our semi-natural pterfour.htm) composition may not yield a pure Multani sequence, but will it not yield a tune which a [Concluded] good composer can easily fit, after suitable modifications, in a play or a movie for APPENDIX A: Notes occurring sequentially in example? Countless number of songs in Indian Multani (index t & corresponding pitch Y t) movies, for example, are based on ragas and Table 4: RAGA MULTANI NOTE SEQUENCE although, barring a few, they do not maintain the raga rules strictly, yet their role in t Y t t Yt Yt t Yt t Yt 1 0 44 0 87 3 130 6 173 7 promoting classical music among the laymen 2 -1 45 -1 88 1 131 7 174 6 cannot be denied. Even a second grade 3 0 46 0 89 0 132 6 175 3 composer who lacks original ideas can perhaps 4 3 47 6 90 6 133 3 176 6 do better. We strongly advise these guys to 5 1 48 3 91 3 134 7 177 3 compose raga based semi-natural tunes as 6 0 49 6 92 1 135 6 178 1 7 -1 50 7 93 0 136 3 179 0 suggested here which would be better than 8 -4 51 6 94 7 137 1 180 -1 indiscriminately borrowing tunes from here and 9 -5 52 3 95 6 138 0 181 0 there and claiming them to be “original” at 10 -5 53 7 96 3 139 -1 182 6 worst or even “inspirational” at best. To the 11 -1 54 6 97 7 140 0 183 3 12 0 55 7 98 6 141 3 184 7 question whether the results are true for the text 13 3 56 8 99 3 142 1 185 6 only [4] or the raga we clarify that as we are 14 1 57 7 100 1 143 0 186 7 analyzing a musical structure, and not a 15 0 58 6 101 0 144 -1 187 8 performance, and as the text [4] is a very 16 -1 59 3 102 -1 145 -4 188 7 standard text and not just any text,it is the raga 17 0 60 7 103 0 146 -5 189 6 18 6 61 6 104 3 147 0 190 7 that is represented. To the question why we 19 3 62 3 105 6 148 6 191 6 have applied ARIMA model to discrete data, 20 6 63 1 106 7 149 3 192 7 we quote a few lines(p.21-22) of [1]:- 21 3 64 0 107 6 150 6 193 6

Soubhik Chakraborty, et al. 35 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

22 1 65 6 108 7 151 7 194 8 Box-Jenkins methodology in model building 23 0 66 3 109 6 152 11 195 7 24 -1 67 6 110 7 153 8 196 8 process. In addition, various exponential 25 0 68 7 111 8 154 7 197 6 smoothing model can be implemented by 26 6 69 6 112 7 155 6 198 3 27 3 70 7 113 6 156 7 199 7 ARIMA models. Although ARIMA models are 28 6 71 8 114 7 157 6 200 6 quite flexible in that they can represent several t Y t t Y t t Yt t Yt t Yt different types of time series, i.e. pure 29 7 72 7 115 6 158 11 201 3 30 6 73 8 116 8 159 8 202 1 autoregressive (AR), pure moving average 31 3 74 7 117 7 160 7 203 0 (MA) and combined AR and MA (ARMA) 32 7 75 8 118 6 161 6 204 -5 33 6 76 6 119 3 162 3 205 -1 series their major limitation is the pre-assumed 34 3 77 7 120 7 163 7 206 0 linear form of the model. [See Box and Jenkins 35 1 78 6 121 11 164 8 207 3 36 0 79 3 122 8 165 7 208 1 (1970) and McKenzie (1984)]

37 -1 80 7 123 7 166 11 209 0 38 -4 81 6 124 6 167 12 There are three stages in fitting of ARIMA 39 -5 82 3 125 11 168 11 40 -1 83 1 126 11 169 8 model are illustrated below:- 41 0 84 0 127 8 170 7 Stage 1- We use the estimated acf 42 3 85 -1 128 7 171 6 43 1 86 0 129 8 172 3 (autocorrelation function) and pacf (partial

autocorrelation function) as guides to choosing APPENDIX B one or more ARIMA models that seem Modeling Through Univariate Box-Jenkins appropriate. The basic idea is this: every ARIMA (Autoregressive Integrated Moving Average Model): ARIMA model has a theoretical acf and pacf ARIMA is one of the popular linear models in associated with it. At the identification stage we time series forecasting during the past three compare the estimated acf and pacf calculated decades. Time series forecasting is an from the available data with various theoretical important area of forecasting in which past acf’s and pacf’s then tentatively choose the observations of the same variable are collected model whose theoretical acf and pacf most and analyzed to develop a model describing the closely resemble the estimated acf and pacf of underlying relationship. The modeling the data series. approach is particularly useful when little Stage 2- Estimation- At this stage we get knowledge is available on the underlying data precise estimate of the coefficients of the model generating process or when there is no chosen at the identification stage. We fit this satisfactory explanatory model that relates the model to the available data series to get prediction variable to other explanatory estimates. This stage provides some warning variables. Much effort has been devoted over signals about the adequacy of the model. In the past several decades to the development and particular, if the estimated coefficients don’t improvement of time series forecasting model. satisfy certain mathematical inequality The popularity of ARIMA model is due to its conditions, that model is rejected. statistical properties as well as the well known

Soubhik Chakraborty, et al. 36 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

Stage 3-Diagnostic test- Box and Jenkins values, according to the following linear (1970) suggested some diagnostic checks to relationship help to determine if an estimated model is Zt = φ1Zt − 1 + φ2Zt − 2 + ...... + φpZt − p + εi statistically adequate. A model that fails this ……..(1) diagnostic test is rejected. Where φ i (i= 1,……,p) are parameters to be

Autoregressive Integrated Moving Average estimated and εi is the residual terms. Model A MA (q) i.e. moving average component of q

A time series is a set of values of a continuous order, which relates each Z t values to the q residual variable Y (Y 1, Y 2… Y n), ordered according to of the q previous Z estimates a discrete index variable t (1,2,..,n). However, it Z = ε − εθ − θ2ε ...... − θ ε t t −1t1 −2t −qtq must be clearly stated that this direct reference ……….(2) to time is not required; a different meaning can Where θ i (i= 1,……,p) are parameters to be be attributed to the index variable, provided estimated. According to Box-Jenkins a highly useful that it is able to order the Y values. With this operator in time series theory is lag or backward

understanding, it is certainly possible to linear operator (B) defined by BZ t = Z t-1 model the structure of a North Indian raga Consider the result of applying the lag operator where the notes come in a sequence . In twice to a series: general, in a given time series the following can B(BZ t) = BZ t-1 = Z t-2

be recognizing and separated: Such a double indication is indicated by B 2 and in • A regular, long-term component of general for any integer k, it can be written variability, termed trend that represent the k B Zt = Zt-k whole evolution pattern of the series. By using the backward operator, equation (1) can be • Stationarity is a critical assumption of time rewritten as

series analysis, stipulating that statistical Z t − φ1Z t −1 − φ 2 Z t − 2 − ...... − φ p Z t − p − ε t = φ(B)Z descriptors of the time series are invariant ……(3) for different ranges of the series. Weak Where φ (B) is the autoregressive operator of order stationarity assumes only that the mean and p defined by variance are invariant. φ (B)= 1- • A regular short term component whose ϕ − 2 − − p 1 B φ 2 B ...... φ p B shape occurs periodically at intervals of s lags of the index variable, currently known Similarly, equation (2) can be written as as seasonality, because this term is also Zt = εt −θ1εt−1 −θ2εt−2...... −θqεt−q derived by application in economics. = θ(B)……….(4) • An AR (p) i.e. autoregressive component of Where θ(B) indicates the moving average operator

order p which relates each value Z t = Y t of q order defined by − − 2 − − q (trend and seasonality) to the p previous Z θ(B)= 1 θ 1 B θ 2 B ...... θ q B

Soubhik Chakraborty, et al. 37 ON ANALYZING THE MELODIC STRUCTURE OF A NORTH INDIAN RAGA

The Autoregressive (AR) and Moving average 3. P. Dorrell, http://www.1729.com/blog/ (MA) component can be combined in an LimitationsOfStatisticalAnalysisOfMusic.html [2005] autoregressive moving average ARMA (p, q) model 4. D. Dutta, Sangeet Tattwa (Pratham Khanda), Brati Prakashani, 5 th ed, 2006(in Bengali) 5. ekrasiya.blogspot.com/2007/09/raga-multani 6. http://en.wikipedia.org/wiki/Markov_chain

7. N. A. Jairajbhoy, The rags of North India: Their Or in lag operator form Structure and Evolution, London; Faber and ϕ − 2 − − p Faber, 1971 (1- 1B φ2B ...... φpB )Z t = 8. C. S. Jones, Indian Classical Music, Tuning and Ragas, http://cnx.org/content/m12459/1.6/ − − 2 − − q 9. E. D. McKenzie, General Exponential Smoothing (1 θ1B θ2B ...... θqB )εt and the Equivalent ARMA Process, Jour. of Finally, Forecasting, 3, 1984, 333-344 Φ (B) Zt = θ (B) ε………..(5) 10. G. Nierhaus, Algorithmic Composition (1st ed.): Paradigms of Automated Music Generation, The value of AR ( φ) term always should be Springer Publishing Company, Inc., 2008 keep in the equation with positive sign and negative sign attached to MA ( θ1 ) which is merely a convention. It makes no difference whether we use a negative or positive sign. There is one more condition about the coefficients of model that they should not exceed unity, which is known as invertibility condition. From the tentative ARIMA models the best models were selected which has significant coefficients with lower values of Mean Absolute Error (MAE), Root Mean Square Error (RMSE), Maximum Absolute Percentage error (Max APE) and residual should be independent in nature which is tested by Ljung- Box test.

Acknowledgement: We thank Rajan P. Parrikar for giving us the permission to quote from his musical archive. We also thank an anonymous referee .

REFERENCES:-

1. G. E. P. Box, G. M. Jenkins and G. C. Reinsel, Time Series Analysis, Forecasting and Control, 3rd ed. Pearson Education, first Indian reprint, 2007 ( 1994, Pearson Edu. Inc. ) 2. S. Chakraborty et. al., Analyzing the melodic structure of a North Indian raga: A Statistical Approach, Electronic Musicological Review, Vol. XII, 2009

Soubhik Chakraborty, et al. 38