||The topic of this article may not meet Wikipedia's general notability guideline. (November 2013)|
|This article needs additional citations for verification. (November 2013)|
|Probability density function
|Cumulative distribution function
|Parameters||length of the interval (real)|
In probability theory, a Xenakis distribution is a probability distribution the graph of whose probability density function on the interval from 0 to a positive number a is a straight line giving the function the value 0 at a. Thus the region under the graph of the density function is a triangle. It is a triangular distribution with parameters 0, a, and 0. It is named after Iannis Xenakis, who used this distribution in his book Musiques formelles (Formal Music), where he described it as the distribution of the length of a line segment that is included inside another fixed line segment.
Probability density function
The probability density function of a Xenakis distribution is a linear function on . Then, as a line segment is symmetric, its median is .
Cumulative distribution function
The cumulative distribution function of a Xenakis distribution is of degree 2; then, to simulate it with the use of the cumulative distribution function, one needs a square root.
Xenakis distribution of parameter 1
When its parameter is 1, a Xenakis distribution is a Beta distribution which parameters are 1 and 2. Hence, a Xenakis variable of parameter 1 can be defined also as the minimum of two variables which are uniform on
- The minimum of 2 Xenakis variables of parameter 1 is Beta with parameters 1 and 4.
Three algorithms are in use when simulating a Xenakis variable of parameter 1:
- The first version uses the definition: Generate 2 uniform random variables then compute the absolute value of their difference;
- A variant is suggested by the definition as a Beta variable: Generate 2 uniform variables then compute their minimum;
- Xenakis used the inverse of the cumulative distribution: The third version below.
Python (language)'s timeit module allows to measure the performances of these algorithms then to compare them:
from timeit import * from random import * from math import * def version1(): return abs(uniform(0,1)-uniform(0,1)) def version2(): return min(uniform(0,1),uniform(0,1)) def version3(): return 1-sqrt(1-uniform(0,1)) print(Timer('x=version1()',"from __main__ import version1").timeit()) print(Timer('x=version2()',"from __main__ import version2").timeit()) print(Timer('x=version3()',"from __main__ import version3").timeit())
Surprisingly, the third version is faster than the others, probably because it is the only one to use only one random uniform variable. It is even possible to make it faster with
def version3(): return 1-sqrt(uniform(0,1))