Harmonic entropy: Difference between revisions

Mention interactive HE graph in SW3
m Text replacement - "Riemann zeta function" to "Riemann zeta function"
Tags: Mobile edit Mobile web edit
 
(6 intermediate revisions by 2 users not shown)
Line 290: 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 301: 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 350: 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 358: 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 [[The Riemann zeta function and tuning|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''.
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 387: 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 [[The Riemann zeta function and tuning|Riemann zeta function]].
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 762: 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''{{'}}|''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:
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$$