In lieu of an abstract, here is a brief excerpt of the content:

164 Chapter 13 Algorithmic Composition Using Probabilistic Methods Chapter 5 introduced the random item stream pattern type. Using the random item stream pattern type, we were able to select randomly among sets of values. In music, we often want some choices to be more likely than others, or a choice might depend upon the previous choice. In this chapter, we will explore probability theory and ways to make biased (and hopefully more musical) choices. 13.1 Introduction to Probability Probability is a branch of mathematics that studies the chance or likelihood that an event will occur. A probability is expressed as a ratio – the number of times a given event is expected to occur divided by the total number of outcomes. If all outcomes are equally likely, the probability of some event is simply the number of outcomes in which the event is present divided by the total number of outcomes. For example, consider a six-sided die where each side is uniquely identified 1, 2, 3, 4, 5, and 6. The probability that a 1 will be rolled is 1:6. The ratio 1:6 may also be expressed as a real number between 0 and 1. Considering the example of the six-sided die, the sum of all possible outcomes is 6/6 or 1.0 (100%). 13.2 The random Pattern A random pattern is created by calling make-random. The first input is a list of items to choose among. In the simplest case, a call to make-random might look like make-random({2, 3, 5, 7, 11, 13, 17}) which generates a stream of small prime numbers chosen randomly from the list. In this case, the probability of choosing any particular number is 1/7. To make some elements more likely than others, we can specify a weight. To associate a weight with an item, the item is replaced by a list containing the item, the keyword weight:, and the weight, a 13.2 The random Pattern 165 numerical value that defaults to 1. Example 13.2.1 illustrates a random pattern where the first element is assigned a weight. Example 13.2.1: Random pattern with weights set note = make-random({{c4 weight: 0.5} d4 e4}) Notice that while weight: has the appearance of a keyword in a parameter list, here it is just a symbol in a list, and since the list is constructed with braces, there are no commas separating any of the list elements. Because the weight for c4 is 0.5, c4 is 1/2 as likely to be selected as d4 or e4, which have default weights of 1. Given that there are 3 notes and the sum of their probabilities must equal 1 (or 100%), and c4 is 1/2 as likely to be selected as d4 or e4, Table 13.2.1 shows the probabilities of the note events. Table 13.2.1: Note probabilities for Example 13.2.1 Note Name C4 D4 E4 Weight 0.2 0.4 0.4 To compute these probabilities, divide the weight of an element (e.g. 0.5 for c4) by the sum of all weights (e.g. 0.5 + 1 + 1, or 2.5). Thus the weight for c4 is 0.5/2.5 = 0.2, and the weight for d4 is 1/2.5 = 0.4. If no weights are specified, the probabilities of all events are equal. The term “white” is often used informally to describe equal probability. This terminology comes from natural white light, which is light in which all visible frequencies (or colors) are present in equal strength. By analogy, we can describe audio as “white noise” when all audible frequencies are equally intense. It turns out that each individual audio sample value of digitized white noise is equally likely and unrelated to other samples, as if sample values were chosen by rolling a die. (Admittedly, it would be hard to find a die with 65,536 sides to represent all the different sample values in 16-bit digital audio!) Thus, a sequence of random outcomes from a die or any other random process with equally probable outcomes can be called “white noise.” In Example 13.2.2, the range of events is the rhythms for a quarter, sixteenth, and eighth note. Example 13.2.2: Random rhythm pattern set rhythm-pattern = make-random(list(q, s, i)) Table 13.2.2 shows the selection of rhythms based on equal probability . [18...

Share