Harmonic entropy: Difference between revisions
-legacy |
m Text replacement - "Riemann zeta function" to "Riemann zeta function" Tags: Mobile edit Mobile web edit |
||
| (12 intermediate revisions by 4 users not shown) | |||
| Line 1: | Line 1: | ||
'''Harmonic entropy''' ('''HE''') is a simple model to quantify the extent to which musical [[chord]]s align with the [[harmonic series]], and thus tend to partly "fuse" into the perception of a single sound with a complex timbre and [[virtual fundamental]] pitch. | '''Harmonic entropy''' ('''HE''') is a simple model to quantify the extent to which musical [[chord]]s align with the [[harmonic series]], and thus tend to partly "fuse" into the perception of a single sound with a complex timbre and [[virtual fundamental]] pitch. | ||
A simple way to state this, is: harmonic entropy measures degree of certainty in the perception of the (virtual) [[root]]. | |||
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 284: | 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 295: | 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 344: | 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 352: | Line 401: | ||
The only technical caveat is that we use the HE of the "unnormalized" probability distribution. However, in the large limit of ''N'', this appears to agree closely with the usual HE. We go into more detail below about this. | The only technical caveat is that we use the HE of the "unnormalized" probability distribution. However, in the large limit of ''N'', this appears to agree closely with the usual HE. We go into more detail below about this. | ||
Our basic approach is: rather than weighting intervals by (''nd'')<sup>0.5</sup>, we choose a different exponent, such as (''nd'')<sup>2</sup>. For an exponent which is large enough (we will show that it must be greater than 1), HE does indeed converge as {{nowrap|''N'' → ∞}}, and we show that this yields an expression related to the [[ | Our basic approach is: rather than weighting intervals by (''nd'')<sup>0.5</sup>, we choose a different exponent, such as (''nd'')<sup>2</sup>. For an exponent which is large enough (we will show that it must be greater than 1), HE does indeed converge as {{nowrap|''N'' → ∞}}, and we show that this yields an expression related to the [[Riemann zeta function]]. We can then use the analytic continuation of the zeta function to obtain an analytically continued curve for the (''nd'')<sup>0.5</sup> weighting, which we then show empirically does indeed appear to be what HE converges on for large values of ''N''. | ||
In short, what we will show is that the Fourier Transform of this unnormalized harmonic Shannon entropy is given by | In short, what we will show is that the Fourier Transform of this unnormalized harmonic Shannon entropy is given by | ||
| Line 381: | Line 430: | ||
It would be nice to show the exact relationship of unnormalized entropy to the normalized entropy in the limit of large ''N'', and whether the two converge to be exactly equal (perhaps given some miniscule adjustment in ''s'' or ''a''). However, we will leave this for future research, as well as the question of how to do an exact derivation of normalized HE. | It would be nice to show the exact relationship of unnormalized entropy to the normalized entropy in the limit of large ''N'', and whether the two converge to be exactly equal (perhaps given some miniscule adjustment in ''s'' or ''a''). However, we will leave this for future research, as well as the question of how to do an exact derivation of normalized HE. | ||
For now, we will start with a derivation of the unnormalized entropy for {{nowrap|''N'' {{=}} ∞}}, as an interesting function worthy of study in its own right—not only because it looks exactly like HE, but because it leads to an expression for unnormalized HE in terms of the [[ | For now, we will start with a derivation of the unnormalized entropy for {{nowrap|''N'' {{=}} ∞}}, as an interesting function worthy of study in its own right—not only because it looks exactly like HE, but because it leads to an expression for unnormalized HE in terms of the [[Riemann zeta function]]. | ||
=== Derivation === | === Derivation === | ||
| Line 756: | 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$$ | ||
| Line 787: | Line 836: | ||
Lastly, you will note that for the special value {{nowrap|''w'' {{=}} 0.5}}, corresponding to the usual <math>\sqrt{nd}</math> weighting, we end up dividing by the term ζ(1). This is the only pole in the zeta function, so we wind up dividing by infinity, making the entire function zero, as pointed out by Martin Gough. However, as we can get arbitrarily close to {{nowrap|''w'' {{=}} 0.5}} and still exhibit the behavior that the unreduced and reduced functions are scaled versions of one another, we can simply use the unreduced version of exp-UHE for {{nowrap|''w'' {{=}} 0.5}} and consider it equivalent to reduced exp-UHE in the limit. | Lastly, you will note that for the special value {{nowrap|''w'' {{=}} 0.5}}, corresponding to the usual <math>\sqrt{nd}</math> weighting, we end up dividing by the term ζ(1). This is the only pole in the zeta function, so we wind up dividing by infinity, making the entire function zero, as pointed out by Martin Gough. However, as we can get arbitrarily close to {{nowrap|''w'' {{=}} 0.5}} and still exhibit the behavior that the unreduced and reduced functions are scaled versions of one another, we can simply use the unreduced version of exp-UHE for {{nowrap|''w'' {{=}} 0.5}} and consider it equivalent to reduced exp-UHE in the limit. | ||
== References == | == References == | ||
| Line 801: | Line 843: | ||
* [https://yahootuninggroupsultimatebackup.github.io/harmonic_entropy Harmonic entropy group on Yahoo] (archive) | * [https://yahootuninggroupsultimatebackup.github.io/harmonic_entropy Harmonic entropy group on Yahoo] (archive) | ||
* [http://www.mikebattagliamusic.com/HE-JS/HE.html Harmonic entropy graph calculator (JavaScript)] | * [http://www.mikebattagliamusic.com/HE-JS/HE.html Harmonic entropy graph calculator (JavaScript)] | ||
== See also == | |||
* [[Harmonic entropy of just intervals]] | |||
* [[Low harmonic entropy linear temperaments]] | |||
* [[User:Sintel/Validation of common consonance measures]] — an informal empirical study which calls into question the effectiveness of harmonic entropy for explaining [[consonance]] | |||
== Todo == | |||
{{todo|inline=1|complete section|text=Add 3HE, both for finite HE and for ''N'' → ∞.}} | |||
{{todo|inline=1|complete section|add table|text=Write-up of fast computation for infinite zeta-UHE, perhaps with a zeta table.}} | |||
{{todo|inline=1|add illustration|text=Addition of many more pictures.}} | |||
[[Category:Terms]] | [[Category:Terms]] | ||