Error measures for DR chords: Difference between revisions

ArrowHead294 (talk | contribs)
m oops
ArrowHead294 (talk | contribs)
Formatting, nowrap stuff
Line 9: Line 9:
<math>x : x + \delta_1 : \cdots : x + \sum_{l=1}^n \delta_l</math>
<math>x : x + \delta_1 : \cdots : x + \sum_{l=1}^n \delta_l</math>


with root real-valued harmonic ''x''. Let <math>D_0 = 0, D_i = \sum_{k=1}^i \delta_k</math> be the delta signature +δ<sub>1</sub> +δ<sub>2</sub> ... +δ<sub>''n''</sub> written cumulatively.
with root real-valued harmonic ''x''. Let <math>D_0 = 0, D_i = \sum_{k=1}^i \delta_k</math> be the delta signature {{nowrap|+δ<sub>1</sub> +δ<sub>2</sub> ... +δ<sub>''n''</sub>}} written cumulatively.


We want to measure the error ''without having to fix any dyad'' (as one might naively fix a dyad and measure errors in the other deltas in relation to the fixed dyad). To do this we solve a least-squares error problem: use a root-sum-square error function and optimize ''x'' (and any free deltas) to minimize that function.
We want to measure the error ''without having to fix any dyad'' (as one might naively fix a dyad and measure errors in the other deltas in relation to the fixed dyad). To do this we solve a least-squares error problem: use a root-sum-square error function and optimize ''x'' (and any free deltas) to minimize that function.
Line 28: Line 28:


{| class="wikitable"
{| class="wikitable"
|+ Error function for various modes and error models
|+ style="font-size: 105%;" | Error function for various modes and error models
|-
|-
!|Domain
! Domain
!|Error model
! Error model
!|Error function
! Error function
|-
|-
!rowspan="3"|Linear
! rowspan="3" | Linear
!|Rooted
! Rooted
||<math>\sqrt{\sum_{i=1}^n \Bigg( \frac{x + D_i}{x} - r_i \Bigg)^2 } = \sqrt{\sum_{i=1}^n \Bigg( 1 + \frac{D_i}{x} - r_i \Bigg)^2 }</math>
| <math>\sqrt{\sum_{i=1}^n \Bigg( \frac{x + D_i}{x} - r_i \Bigg)^2 } = \sqrt{\sum_{i=1}^n \Bigg( 1 + \frac{D_i}{x} - r_i \Bigg)^2 }</math>
|-
|-
!|Pairwise
! Pairwise
||<math>\sqrt{\sum_{0\leq i<j\leq n} \Bigg( \frac{x + D_j}{x + D_i} - \frac{r_j}{r_i} \Bigg)^2 }</math>
| <math>\sqrt{\sum_{0\leq i<j\leq n} \Bigg( \frac{x + D_j}{x + D_i} - \frac{r_j}{r_i} \Bigg)^2 }</math>
|-
|-
!|All-steps
! All-steps
||<math>\sqrt{\sum_{0\leq i<n} \Bigg( \frac{x + D_{i+1}}{x + D_i} - \frac{r_{i+1}}{r_i} \Bigg)^2 }</math>
| <math>\sqrt{\sum_{0\leq i<n} \Bigg( \frac{x + D_{i+1}}{x + D_i} - \frac{r_{i+1}}{r_i} \Bigg)^2 }</math>
|-
|-
!rowspan="3"|Logarithmic<br/>(nepers)
! rowspan="3" | Logarithmic<br />(nepers)
!|Rooted
! Rooted
||<math>\sqrt{\sum_{i=1}^n \Bigg(\log \frac{x + D_i}{r_i x} \Bigg)^2}</math>
| <math>\sqrt{\sum_{i=1}^n \Bigg(\log \frac{x + D_i}{r_i x} \Bigg)^2}</math>
|-
|-
!|Pairwise
! Pairwise
||<math>\sqrt{\sum_{0\leq i<j\leq n} \Bigg(\log \frac{x + D_j}{x + D_i} - \log \frac{r_j}{r_i} \Bigg)^2}</math>
| <math>\sqrt{\sum_{0\leq i<j\leq n} \Bigg(\log \frac{x + D_j}{x + D_i} - \log \frac{r_j}{r_i} \Bigg)^2}</math>
|-
|-
!|All-steps
! All-steps
||<math>\sqrt{\sum_{0\leq i<n} \Bigg(\log \frac{x + D_{i+1}}{x + D_i} - \log \frac{r_{i+1}}{r_i} \Bigg)^2}</math>
| <math>\sqrt{\sum_{0\leq i<n} \Bigg(\log \frac{x + D_{i+1}}{x + D_i} - \log \frac{r_{i+1}}{r_i} \Bigg)^2}</math>
|}
|}
To convert nepers to cents, multiply by <math>\frac{1200}{\log 2}.</math>
To convert nepers to cents, multiply by <math>\frac{1200}{\log 2}.</math>


== Solution methods ==
== Solution methods ==
This section gets into the depths of mathematical optimization methods used to minimize DR error. (Optimization is a whole field and there are many different methods; the reason most of those methods exist is to find solutions when finding them symbolically is infeasible.)
This section gets into the depths of mathematical optimization methods used to minimize DR error. (Optimization is a whole field and there are many different methods; the reason most of those methods exist is to find solutions when finding them symbolically is infeasible.)
=== Analytic ===
=== Analytic ===
==== Fully DR, rooted linear ====
==== Fully DR, rooted linear ====
Line 79: Line 81:
where ''y'' represents the free delta +?.
where ''y'' represents the free delta +?.


We can set the partial derivatives with respect to ''x'' and ''y'' of the inner expression equal to zero (since the derivative of sqrt() is never 0) and use SymPy to solve the system symbolically:
We can set the partial derivatives with respect to ''x'' and ''y'' of the inner expression equal to zero (since the derivative of <code>sqrt()</code> is never 0) and use SymPy to solve the system symbolically:


<syntaxhighlight lang="py">
<syntaxhighlight lang="py">
Line 98: Line 100:
</syntaxhighlight>
</syntaxhighlight>


The unique solution with ''x'' > 0 is
The unique solution with {{nowrap|''x'' &gt; 0}} is


<math>
<math>
Line 152: Line 154:


=== BFGS-B (one related delta set, arbitrary free deltas) ===
=== BFGS-B (one related delta set, arbitrary free deltas) ===
We let ''x''<sub>1</sub> = ''x'' and include additional free variables ''x''<sub>2</sub>, ..., ''x''<sub>n</sub>, one for every additional +?, after coalescing strings of consecutive +?'s into one +? and after trimming leading and trailing free delta segments.
We let {{nowrap|''x''<sub>1</sub> {{=}} ''x''}} and include additional free variables ''x''<sub>2</sub>, ..., ''x''<sub>n</sub>, one for every additional +?, after coalescing strings of consecutive +?'s into one +? and after trimming leading and trailing free delta segments.


BFGS-B is a quasi-Newton optimization method (based on BFGS) particularly suited for this problem:
BFGS-B is a quasi-Newton optimization method (based on BFGS) particularly suited for this problem:
* The error function is smooth, allowing use of gradients
* The error function is smooth, allowing use of gradients
* Fast convergence, requiring at worst 20 iterations for accuracy
* Fast convergence, requiring at worst 20 iterations for accuracy
* Naturally deals with the ''x'' > 0 constraint using a log barrier and minimizing the transformed function using the unconstrained BFGS method
* Naturally deals with the {{nowrap|''x'' &gt; 0}} constraint using a log barrier and minimizing the transformed function using the unconstrained BFGS method
* Acceptable memory usage given a realistic number of parameters for practical DR chords (up to 3 interior free delta segments, thus 4 parameters).
* Acceptable memory usage given a realistic number of parameters for practical DR chords (up to 3 interior free delta segments, thus 4 parameters).


Line 413: Line 415:


== External links ==
== External links ==
* [https://inthar-raven.github.io/delta/ Inthar's DR chord explorer (includes least-squares error calculation in both domains and multiple error models)]
* [http://inthar-raven.github.io/delta/ Inthar's DR chord explorer (includes least-squares error calculation in both domains and multiple error models)]
 
[[Category:Math]]
[[Category:Math]]