User:Arseniiv/Fitting: Difference between revisions
fitting a periodic scale to an equal division |
(No difference)
|
Revision as of 12:11, 9 December 2023
How to fit a scale to a scale of particular structure (say, equal-step tuning, MOS scale etc.).
This is eternal work in progress.
Any periodic scale
The methods here may be applicable to aperiodic scales specifiable with finite data (like “aperiodic MOS scales”[1]) but I’m not considering them yet.
To edX
We’ll consider that periods of an initial scale and an N-ed it’s matched to are the same, but they needn’t be. Let [math]\displaystyle{ X }[/math], the period of both, be specified in cents or other logarithmic units, as all other intervals.
Let’s say k-steps from a given note upwards are [math]\displaystyle{ 0 = I_0 \lt I_1 \lt \ldots \lt I_m = X }[/math].
A step of N-edX is [math]\displaystyle{ S := X/N }[/math], so now we round [math]\displaystyle{ I_k }[/math] to integer multiples [math]\displaystyle{ S }[/math] to get their equalized variants:
- [math]\displaystyle{ E_k := \mathsf{round}(s I_k) / s }[/math][2].
Then we can get errors of this approximation as [math]\displaystyle{ \Delta_k := I_k - E_k }[/math]. Note that always [math]\displaystyle{ -\frac S2 \le \Delta_k \le +\frac S2 }[/math] but the largest negative error and the largest positive error might not be “balanced” and sum to zero, nor any other measure of well-fitting might be minimized: all because we fixed ourselves to necessarily fit one of the notes exactly ([math]\displaystyle{ I_0 }[/math] being exactly zero). We can fix that by subtracting the average [math]\displaystyle{ d }[/math] of all [math]\displaystyle{ \Delta_k }[/math] that we are interested in (arithmetic mean, RMS or something else), or, in the simplest case of minimizing the largest absolute error attained, subtract [math]\displaystyle{ d := \frac12(\min_k \Delta_k + \max_k \Delta_k) }[/math].
Then, [math]\displaystyle{ E_k }[/math] is still our true fit of [math]\displaystyle{ I_k }[/math] in case of our average being the last case, arithmetic mean, RMS and several other kinds of averagings because we’ll still have [math]\displaystyle{ -\frac S2 \le \Delta_k - d \le +\frac S2 }[/math].
- ↑ for example, infinite Fibonacci words …ABABBABBABABBAB… grown from an L-system {A → B, B → BA}
- ↑ if there’s no [math]\displaystyle{ \mathsf{round}(x) }[/math] function in your environment, it can be defined as [math]\displaystyle{ (x + \frac12) \bmod 1 + \frac12 }[/math] using floating-point remainder or [math]\displaystyle{ \lfloor x + \frac12 \rfloor - \frac12 }[/math] using floor [math]\displaystyle{ \lfloor\ldots\rfloor }[/math]; these agree up to cases when [math]\displaystyle{ x }[/math] is exactly a half-odd-integer