I'm working on a little project, which is in early development stage right now. What I'm trying to figure out is how do I generate random music, especially notes. By googling I've only managed to find ransom note generator and lots of random music, where word random has nothing to do with definition of random variable :) I don't know if anybody have done this before and I wish to know about presence of such work to give me some guidance. Here some of my naive ideas:

Given the root note of the chord generate a random note with mean of that note and some deviation, which might be controlled by part of the bar which you are currently in.

I would prefer to set 0 as a reference to root note in every bar and generate integers, which would mean how many scale intervals up or down melody should deviate from the root. But this approach might make joining melody bars together harder, so another idea is to use the key of whole part as a reference note and then change the mean of random variable according to which bar corresponds to which key.

So now, that I have explained a little on how do I expect the mean of the random note to be, lets move on to random number generation in the bar or a piece of music. What I need is a sequence of integers with mean $0$. Natural candidates could be

  1. Sum of two Poisson distributed variables, one of them should be multiplied by $-1$
  2. The same thing with binomial random variables.

Maybe you can suggest something better?

For the rhythm generation I will probably set the fixed number of maximum notes per bar and then generate sequence of zeroes and ones, the one will indicate that beat is changing. Maybe I will will set probability of zero conditional on how many zeroes were before. If anybody has ideas I would love to hear them!

  • 1
    $\begingroup$ Maybe this could give you some ideas: ted.com/talks/… $\endgroup$
    – JRN
    Aug 7, 2013 at 5:04

1 Answer 1


A very cute question! Here's a partial cute answer: Chopin, mazurkas and Markov chains. I am not a musician myself, so I can't really expand and give a meaningful answer. But you should read that paer.

  • $\begingroup$ Link Broken. It looks like the paper is not publicly available either. :( $\endgroup$
    – nabulator
    Jul 14, 2018 at 16:29
  • 1
    $\begingroup$ Maybe this could be better: rss.onlinelibrary.wiley.com/doi/full/10.1111/…. They must have been doing redesigns that drastically improve user experience (eyeroll). $\endgroup$
    – StasK
    Jul 25, 2018 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.