Harmonic entropy: Difference between revisions
→See also: add link to Sintel's page |
ArrowHead294 (talk | contribs) m update shortcut to something easier to type |
||
| (6 intermediate revisions by 3 users not shown) | |||
| Line 4: | Line 4: | ||
Harmonic entropy was invented by [[Paul Erlich]] and developed extensively on the Yahoo! tuning and harmonic_entropy lists, and draws from prior research by Parncutt and Terhardt. Various later contributions to the model have been made by [[Steve Martin]], [[Mike Battaglia]], [[Keenan Pepper]], and others. | Harmonic entropy was invented by [[Paul Erlich]] and developed extensively on the Yahoo! tuning and harmonic_entropy lists, and draws from prior research by Parncutt and Terhardt. Various later contributions to the model have been made by [[Steve Martin]], [[Mike Battaglia]], [[Keenan Pepper]], and others. | ||
An interactive harmonic entropy graph can be found in [[Scale Workshop]] version 3 in the Analysis tab. | |||
Note: the terms dyad, triad and tetrad usually refer to chord with 2, 3, or 4 [[pitch class]]es. But in this discussion they refer to chords with 2, 3, or 4 ''pitches''. Thus {{dash|C, E, G, C}} is a tetrad instead of a triad. | Note: the terms dyad, triad and tetrad usually refer to chord with 2, 3, or 4 [[pitch class]]es. But in this discussion they refer to chords with 2, 3, or 4 ''pitches''. Thus {{dash|C, E, G, C}} is a tetrad instead of a triad. | ||
| Line 288: | Line 290: | ||
We note that the left factor in the convolution product is always the same ''S''(−''c''), which is not dependent on ''j'' in any way. Since convolution distributes over addition, we can factor the ''S'' out of the summation to obtain | We note that the left factor in the convolution product is always the same ''S''(−''c''), which is not dependent on ''j'' in any way. Since convolution distributes over addition, we can factor the ''S'' out of the summation to obtain | ||
$$\displaystyle \psi(c) = \left[S \ast \left(\sum_{j \in J} \frac{\delta_{-\cent(j)}}{\|j\|}\right)\right](-c)$$ | <nowiki>$$\displaystyle \psi(c) = \left[S \ast \left(\sum_{j \in J} \frac{\delta_{-\cent(j)}}{\|j\|}\right)\right](-c)$$</nowiki> | ||
We can clean up this notation by defining the auxiliary distribution ''K'': | We can clean up this notation by defining the auxiliary distribution ''K'': | ||
$$\displaystyle K(c) = \sum_{j \in J} \frac{\delta_{-\cent(j)}}{\|j\|}$$ | <nowiki>$$\displaystyle K(c) = \sum_{j \in J} \frac{\delta_{-\cent(j)}}{\|j\|}$$</nowiki> | ||
| Line 299: | Line 303: | ||
$$\displaystyle \psi(c) = \left[S \ast K\right](-c)$$ | $$\displaystyle \psi(c) = \left[S \ast K\right](-c)$$ | ||
If we discretize this to an integer array of cents, give S a standard deviation of 17 cents, and represent all delta functions in K as a vertical line of height 1, we can visualize S and K like so: | |||
[[File:S function.png|alt=S function with a standard deviation of 17 cents|frameless]][[File:K function.png|alt=Visualization of K(c) on 1201 samples for intervals of up to numerator/denominator of 200|frameless]] | |||
==== Convolution product for ρ<sub>a</sub>(''c'') ==== | ==== Convolution product for ρ<sub>a</sub>(''c'') ==== | ||
| Line 348: | Line 358: | ||
We have succeeded in representing harmonic Rényi entropy in simple terms of two convolution products, each of which can be computed in {{nowrap|''O''(''N'' log ''N'')}} time. | We have succeeded in representing harmonic Rényi entropy in simple terms of two convolution products, each of which can be computed in {{nowrap|''O''(''N'' log ''N'')}} time. | ||
==== Python Example ==== | |||
<syntaxhighlight lang="python3" line="1"> | |||
import numpy as np | |||
def gaussian(x, stdev): | |||
return 1.0 / (stdev * np.sqrt(2.0 * np.pi)) * np.exp( -0.5 * (x**2) / (stdev**2) ) | |||
x = np.array(range(1201)) | |||
intervals = [] | |||
interval_weights = [] | |||
for i in range(1, 200): | |||
for j in range(1, 200): | |||
if np.gcd(i,j) == 1 and 1.0 * i / j >= 1.0 and 1.0 * i / j <= 2.0: | |||
intervals.append(1.0 * i / j) | |||
interval_weights.append(np.sqrt(i * j)) | |||
intervals = np.array(intervals) | |||
interval_weights = np.array(interval_weights) | |||
intervals_cents = 1200 * np.log2(intervals) | |||
K = np.zeros(len(x)) | |||
for i in range(len(intervals)): | |||
closest_cent = np.rint(intervals_cents[i]).astype(int) # change this if x has non integers | |||
if K[closest_cent] == 0.0 or K[closest_cent] < 1.0 / interval_weights[i]: | |||
K[closest_cent] = 1.0 / interval_weights[i] | |||
x_gaussian = range(100) | |||
gaussian_deviation_cents = 17 | |||
S = np.array([gaussian(x-50, gaussian_deviation_cents) for x in x_gaussian]) | |||
a = 100 | |||
reyni_entropy = 1.0 / (1.0 - a) * np.log( np.convolve(K**a, S**a, 'same') / np.convolve(K, S, 'same')**a ) | |||
</syntaxhighlight> | |||
== Extending HE to ''N'' {{=}} ∞: zeta-HE == | == Extending HE to ''N'' {{=}} ∞: zeta-HE == | ||
| Line 760: | Line 805: | ||
$$\displaystyle \mathcal{F}\left\{K(n)\right\}(t) = \sum_{j \in J} \frac{e^{i t \log (j_n/j_d)}}{(j_n \cdot j_d)^{w}}$$ | $$\displaystyle \mathcal{F}\left\{K(n)\right\}(t) = \sum_{j \in J} \frac{e^{i t \log (j_n/j_d)}}{(j_n \cdot j_d)^{w}}$$ | ||
Now, suppose we want to analytically continue this so that the set ''J'' is the set of all reduced rational numbers. We can first do so by starting again with unreduced rationals, but expressing each rational not as {{sfrac|''n''|''d''}}, but rather as {{nowrap|{{sfrac|''n''{{ | Now, suppose we want to analytically continue this so that the set ''J'' is the set of all reduced rational numbers. We can first do so by starting again with unreduced rationals, but expressing each rational not as {{sfrac|''n''|''d''}}, but rather as {{nowrap|{{sfrac|''n''{{``}}|''d''{{-`}}}} · {{sfrac|''c''|''c''}}}}, where ''n''{{``}} and ''d''{{-`}} are coprime, and ''c'' is the GCD of both. For example, we would express {{sfrac|6|4}} as {{nowrap|{{sfrac|3|2}} · {{sfrac|2|2}}}}. Doing so, and assuming that we denote the set of unreduced rationals by ''U'', we get the following equivalent expression of the same convolution kernel above: | ||
$$\displaystyle \mathcal{F}\left\{K(n)\right\}(t) = \sum_{j \in \mathbb{U}} \frac{e^{i t \log (\frac{j_c j_{n'}}{j_c j_{d'}})}}{(j_c j_{n'} \cdot j_c j_{d'})^{w}} = |\zeta(w+i t)|^2$$ | $$\displaystyle \mathcal{F}\left\{K(n)\right\}(t) = \sum_{j \in \mathbb{U}} \frac{e^{i t \log (\frac{j_c j_{n'}}{j_c j_{d'}})}}{(j_c j_{n'} \cdot j_c j_{d'})^{w}} = |\zeta(w+i t)|^2$$ | ||