Andreas Pfenning
A probability distribution generator outputs a singe number based the particular distribution and the input parameters. These functions were created to supplement the uniform random generator (real-random). There are two types of distributions: continuous and discrete. For either distribution, looking at the diagrams will show you the likely range of outputs. In a continuous distribution, the likelihood of returning a value between two points on the x-axis is equal to the area under the curve between those two points. Every continuous distribution has the property that the total area under the curve = 1. In a discrete distribution, only integers >= 0 are allowed as output. Each one of these numbers has a probability of being returned which is equal to the height of the bar in the diagram. For the user's convenience, many distributions have optional bounds that come in useful for certain applications.
Example 1 Varying time with a continuous distribution generator
One of the most common distributions found in algorithmic
composition is known as the Poisson process. This
consists of a sequence of notes or beats separated by an exponential amount
of time. The set of sounds will
have the following property: every
point in time is equally likely to be that start of a note. This
is just one example how to use the exponential distribution. The
first input parameter, .25, spreads the distribution out so that higher
values are more likely. The second
input is optional and is an upper bound on the output. The
resulting sound can be heard in the file .
try-exponential ()
(play
(seqrep (i 20)
(pluck c4 (* 0.5 (exponential-dist .25 2.0))))))
Example 2 Varying pitch with a discrete distribution generator
Discrete distribution generators are useful for changing pitch. Constraining the output to a whole number means that every pitch is going to be a specific note. In the case of the binomial distribution, both parameters together determine the mean. One way to get feel for how the difference parameters affect the distribution is to print values as you generate them. Distribution parameters may require some tweaking to produce a desired affect. In some cases, altering the parameters can yield unexpected and interesting sounds. The resulting sound can be heard in the file binomial.wav.
(defun
try-binomial ()
(play
(seqrep (i 20)
(pluck
(+ (binomial-dist 6 .5) c4) 0.1))))
Example 3 Using granular synthesis with pitch distribution
In granular synthesis, interesting sounds can be made by having a pitch vary by a distribution rather than just the uniform random. My goal was to create a granular synthesis function that can take in any distribution (within the bounds of granular synthesis) and vary the pitch of the tone based on that distribution. To do this it is necessary to create a continuation out of the distribution function. This can be done with lambda expression.
(defun
make-gamma (nu high)
(lambda
() (gamma-dist nu high)))
After the continuation is made, any parameters can still be passed to it. This continuation can now be used as input to the granular-synthesis function. This allows the function to be called again at every iteration of the synthesis loop and have different output. A possible results sound based on your samples file is pitch-granular.wav.
(defun
try-pitch-dist ()
(play
(stretch 4
(simrep
(i 4)
(pitch-dist-granulate
"samples.wav" 0.04 0.0 0.02 0.001
(make-gamma
2.0 5.0) 0 0)))))
Example 4 Using granular synthesis with grain length distribution
The length of grains can also be made to vary by a distribution passed in as a continuation. Here is an example. A possible results sound based on your samples file is length-granular.wav.
(defun
make-gauss (xmu sigma low high)
(lambda
() (gauss-dist xmu sigma low high)))
(defun
try-len-dist ()
(play
(stretch 4
(simrep
(i 2)
(len-dist-granulate
"samples.wav"
(make-gauss
0.0 1.0 0.1 .5) 0.02 0.001 2.0 0 0)))))
Documentation
(linear-dist g)
g the maximum output possible
must be greater than 0
returns a value generated based on this probability distribution
The linear distribution is useful for generating for generating time and pitch intervals. It outputs values between 0 and g. It is a continuous distribution.
Linear Distribution G=1
(exponential-dist delta
[high])
delta the degree to which the distribution is sloped
a larger delta gives a steeper downward slope
must be greater than 0
high puts an artificial bound on the maximum output
any value above high is discarded
another one is chosen based on the distribution
returns a value generated based on this probability distribution
The exponential distribution generates values greater than 0. It can be used to generate time intervals. A series of exponentials can be used to generate a uniformly random set of points in an interval. The exponential distribution is memory-less. This means that if it is used to generate the length of the note, the note is equally likely to end at every point in time. It is a continuous distribution, but geometric-dist is the discrete form.
Exponential Distribution delta=1
(gamma-distnu
[high])
nu how quickly the distribution increases, then decreases
a higher nu increases and decreases and more slowly than a low one
must be an integer greater than 0
high puts an artificial bound on the maximum output
any value above high is discarded
another one is chosen based on the distribution
returns a value generated based on this probability distribution
The gamma distribution outputs values greater than 0. It has a mean of nu and a mode of around nu-1. This distribution can produce a gradual easing of grain frequency if it is used in granular synthesis. It is a continuous distribution.
Gamma Distribution nu = 4
(bilateral-exponential-distxmutau [low] [high])
xmu the center of the double exponential
tau a variable which measures how spread out the distribution is
a larger tau means the output values are farther from the mean
must be greater than 0
low puts an artificial bound on the minimum output
any value below low is discarded
high puts an artificial bound on the maximum output
any value above high is discarded
another one is chosen based on the distribution
another
one is chosen based on the distribution
returns a value generated based on this probability distribution
This distribution is similar to the exponential, except it is centered at 0 and can output negative values as well. Like the exponential, it can be used to generate the placement of grains or time intervals, however it might be necessary to add a lower bound so as not to compute a negative start time. It is a continuous distribution.
Bilateral Exponential
(cauchy-disttau [low] [high])
tau a variable which measures how spread out the distribution is
a larger tau means the output values are farther from the mean
must be greater than 0
low puts an artificial bound on the minimum output
any value below low is discarded
high puts an artificial bound on the maximum output
any value above high is discarded
another one is chosen based on the distribution
another one is chosen based on the distribution
returns a value generated based on this probability distribution
The cauchy is a symmetric distribution with a high peak at 0. It can be used to generate dense pockets of sound. It is a continuous distribution and has no inherent bound on output.
Cauchy Distribution tau = 1
(hyperbolic-cosine-dist [low] [high])
low puts an artificial bound on the minimum output
any value below low is discarded
high puts an artificial bound on the maximum output
any value above high is discarded
another one is chosen based on the distribution
another one is chosen based on the distribution
returns a value generated based on this probability distribution
The hyperbolic cosine distribution is a symmetric distribution with its peak at 0. It is continuous has no inherent bound on output.
Hyperbolic Cosine Distribution
(logistic-dist alpha beta [low] [high])
alpha a parameter than primarily affects dispersion
a larger alpha will be output values closer to the mean
must be greater than 0
beta influences the mean
low puts an artificial bound on the minimum output
any value below low is discarded
high puts an artificial bound on the maximum output
any value above high is discarded
another one is chosen based on the distribution
another one is chosen based on the distribution
returns a value generated based on this probability distribution
The logistic distribution is symmetric and has a centered peak at 0. It is continuous and has no inherent bound on output.
Logistic Distribution alpha = 1, beta = 2
(arc-sine-dist)
returns a value generated based on this probability distribution
The arc sine distribution outputs values between 0 and 1. It is symmetric, but more likely to generate values closer to 0 and 1.
Arc Sine Distribution
(gauss-distxmu sigma [low] [high])
xmu the mean of the normal distribution
sigma the standard deviation of the distribution
must be greater than 0
low puts an artificial bound on the minimum output
any value below low is discarded
high puts an artificial bound on the maximum output
any value above high is discarded
another one is chosen based on the distribution
another one is chosen based on the distribution
returns a value generated based on this probability distribution
The gauss or gauss-laplace continuous distribution is a linear function of the normal distribution. It has numerous applications including durations. There is no inherent bound on its output.
Gauss-Laplace Distribution xmu = 0, sigma = 1
(beta-dist a b)
a a measure of the height on the right side of the u shaped curve
must be greater than 0
b a measure of the height on the left side of the u shaped curve
must be greater than 0
returns a value generated based on this probability distribution
The arc sine distribution outputs values between 0 and 1. Like the arc sine distribution, it is more likely to output values close to 0 and 1, however, it is only symmetric when a = b.
Beta Distribution alpha = .5, beta = .25
(bernouilli-distpxl [x1] [x2])
pxl the probability that the value x1 will be chosen
x1 a single value that has probability px1 of being returned, 1 is the default
x2 a single value that has probability 1 px1 of being returned, 0 is the default
returns either x1 or x2
This is a very simple discrete distribution, but useful for generating the binomial and the geometric distribution. By convention return x1 is viewed as a success while return x2 is viewed as a failure.
(binomial-dist n p)
n the number Bernoulli trials run
p the probability of success in the Bernoulli trial
returns a value generated based on this probability distribution
This is a discrete distribution that is defined to be the number of success in n trials where the probability of success is p. The mean is nxp.
(geometric-dist p)
p the probability of success in the Bernoulli trial
returns a value generated based on this probability distribution
This is a discrete distribution that is defined to be the number of failures before a success is achieve in a Bernoulli trial.
(poisson-dist delta)
delta the density of the distribution in a sequence and mean value returned
returns a value generated based on this probability distribution
This is a discrete distribution that generates a uniformly distributed set of values across an interval if run sequentially. Therefore, it is often used to choose the amount of time between sounds.
(pitch-dist-granulate filename grain-dur grain-devioiioi-dev pitch-dist [file-start] [file-end])
filename name of the file
dist the distribution that determines the length of the grains
ioi the basic inter-onset-interval for grains
ioi-dev ioi is actually: ioi + random(0, ioi-dev)
pitch-dev grains are resampled at rate between 1 and pitch-dev
file-start when to start reading the file (an offset from start)
the default is 0
file-end when to stop reading the file (an offset from end)
the default is 0
returns a set of sound grains created from the input file
This is a granular synthesis function based on the one by Roger B. Dannenberg. The pitch of the grains will be based on the distribution you give to it. The distribution must be passed in as a continuation.
(len-dist-granulate filename distioiioi-dev pitch-dev [file-start] [file-end])
filename name of the file
grain-dur the duration of a grain
grain-dev grain dur is actually grain-dur + random(0, grain-dev)
ioi the basic inter-onset-interval for grains
ioi-dev ioi is actually: ioi + random(0, ioi-dev)
pitch-dist the distribution of the alteration in pitch to the grains
the distribution values should be > 1.
file-start when to start reading the file (an offset from start)
the default is 0
file-end when to stop reading the file (an offset from end)
the default is 0
returns a set of sound grains created from the input file
This is a granular synthesis function based on the one by Roger B. Dannenberg. The length of the grains will be based on the distribution you give to it. The distribution must be passed in as a continuation.
References
Lorrain,
Dennis. 1980. "A Panoply of Stochastic 'Canons'."
Computer Music Journal 4(1):53-81.
This
was work was as an assignment for Introduction to Computer Music taught
by Roger B. Dannenberg