From: Atte Tenkanen <attenka_at_utu.fi>

Date: Sun 05 Feb 2006 - 18:13:05 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Feb 05 18:23:41 2006

Date: Sun 05 Feb 2006 - 18:13:05 EST

> If I calculate a transition probability matrix, first order markov 12x12

*> or second order 144x144 from musical pitch classes (0-11), is it possible
**> to generate pitch class strings similar as those original strings using
**> those probability matrix with R? If, how?
**>
**> Atte Tenkanen, Turku, Finland
**>
*

I found this kind of solution:

j=1; a1=c();

Generated_Melody=c(1); #first note as a seed
a1=sample(1:12, size=1, prob=PT_matrix[j,]) # a seed for the loop following

for (i in 1:100){ # length of the generated melody will be 100

Generated_Melody=c(Generated_Melody,a1) a1=sample(1:12, size=1, prob=PT_matrix[a1,])}

# Generated_Melody=Generated_Melody-1; # to picht classes # Generated_Melody=Generated_Melody+59; # or to midi pitches

Atte Tenkanen

PS. Here is my page considering the course in which we use R for music
analysis...

http://musiikintutkimus.blogspot.com/

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Feb 05 18:23:41 2006

*
This archive was generated by hypermail 2.1.8
: Sun 05 Feb 2006 - 21:03:42 EST
*