N2D3P9: Difference between revisions

Dave Keenan (talk | contribs)
Justification rewritten from 1st person to 3rd person to be consistent with the rest of the article.
Dave Keenan (talk | contribs)
Replaced "5-rough" with "2,3-reduced" or "2,3-equivalent" in all but one place.
Line 1: Line 1:
'''<math>\text{N2D3P9}</math>''', or Entoo-Deethree-Peenine, is a fictional character in the Star Wars franchise. In an alternative timeline, the young Anakin Skywalker assembles the droid from the parts of three other droids: R<span style="color:#FF0000">2D</span>2, C<span style="color:#FF0000">3P</span>0 and <span style="color:#FF0000">N</span>R-N9<span style="color:#FF0000">9</span>. We're only joking, but we hope this helps with remembering and pronouncing the name.
'''<math>\text{N2D3P9}</math>''', or Entoo-Deethree-Peenine, is a fictional character in the Star Wars franchise. In an alternative timeline, the young Anakin Skywalker assembles the droid N2D3P9 from the parts of three other droids: R<span style="color:#FF0000">2D</span>2, C<span style="color:#FF0000">3P</span>0 and <span style="color:#FF0000">N</span>R-N9<span style="color:#FF0000">9</span>. We're only joking, but we hope this helps with remembering and pronouncing the name.


'''<math>\text{N2D3P9}</math>''' is a mathematical function which was developed to help in designing the [https://en.xen.wiki/w/Sagittal_notation Sagittal microtonal notation]. Given a pitch ratio <math>\frac{n}{d}</math>, <math>\text{N2D3P9}</math> estimates its rank in popularity among all rational pitches in musical use. A low value of <math>\text{N2D3P9}</math> indicates that the ratio is used often, and so should have a simple accidental symbol, while a high value indicates that the ratio is used rarely and so can have a more complex symbol if necessary. The name "N2D3P9" is an abbreviation of key components of its formula, which will be described in detail later.
'''<math>\text{N2D3P9}</math>''' is a mathematical function which was developed to help in designing the [https://en.xen.wiki/w/Sagittal_notation Sagittal microtonal notation]. Given a pitch ratio <math>\frac{n}{d}</math>, <math>\text{N2D3P9}</math> estimates its rank in popularity among all rational pitches in musical use. A low value of <math>\text{N2D3P9}</math> indicates that the ratio is used often, and so should have a simple accidental symbol, while a high value indicates that the ratio is used rarely and so can have a more complex symbol if necessary. The name "N2D3P9" is an abbreviation of key components of its formula, which will be described in detail later.
Because factors of <math>2</math> and <math>3</math> in pitch ratios are already notated by changing octaves or moving along the chain of fifths (... B♭♭ F♭ C♭ G♭ D♭ A♭ E♭ B♭ F C G D A E B F♯ C♯ G♯ D♯ A♯ E♯ B♯ Fx ...), <math>\text{N2D3P9}</math> only operates on ratios that have had their factors of <math>2</math> and <math>3</math> removed. For example, there are various numbers of factors of <math>2</math> and <math>3</math> in the following ratios: <math>\frac{16}{15}, \frac{10}{9}, \frac{6}{5}, \frac{5}{4}, \frac{27}{20}, \frac{45}{32}, \frac{64}{45}, \frac{40}{27}, \frac{8}{5}, \frac{5}{3}, \frac{9}{5}, \frac{15}{8}</math>, but when their factors of <math>2</math> and <math>3</math> are removed, they all reduce to <math>\frac{1}{5}</math> or <math>\frac{5}{1}</math>, and so they can all be notated using the same microtonal accidental, pointing either up or down, combined with different letters and sharps or flats. We say that <math>\frac{1}{5}</math> or <math>\frac{5}{1}</math> is the "2,3-reduced" or "[https://en.wikipedia.org/wiki/Rough_number 5-rough]" form of these pitch ratios.
Because <math>\frac{1}{5}</math> and <math>\frac{5}{1}</math> use the same accidental pointing either up or down, and because <math>\text{N2D3P9}</math> only operates on ratios whose numerator is larger than their denominator (superunison ratios), <math>\frac{5}{1}</math> can represent this entire equivalence class for the purpose of notation design.


== Formula ==
== Formula ==


Before describing how to calculate <math>\text{N2D3P9}</math>, we describe two simpler functions that are used in calculating it.
Before describing how to calculate <math>\text{N2D3P9}</math>, we define three simpler terms that are used in its formula:


# '''copfr''', which stands for "<u>C</u>ount <u>O</u>f <u>P</u>rime <u>F</u>actors with <u>R</u>epeats". It applies to any positive integer. For example <math>175</math> has the prime factorization <math>5 × 5 × 7</math>, which has 3 factors including the repeat of <math>5</math>, so <math>\text{copfr}(175) = 3</math>. <math>\text{copfr}(1) = 0</math>. <math>\text{copfr}</math> is also called the "[https://en.wikipedia.org/wiki/Prime_omega_function big omega]" function, <math>Ω</math>.
# '''2,3-reduced''' ratios, which are also known as "[https://en.wikipedia.org/wiki/Rough_number 5-rough]" ratios. Because factors of <math>2</math> and <math>3</math> in pitch ratios are already notated by changing octaves or moving along the chain of fifths (... B♭♭ F♭ C♭ G♭ D♭ A♭ E♭ B♭ F C G D A E B F♯ C♯ G♯ D♯ A♯ E♯ B♯ Fx ...), <math>\text{N2D3P9}</math> only operates on ratios that have had their factors of <math>2</math> and <math>3</math> removed. For example, there are various numbers of factors of <math>2</math> and <math>3</math> in the following ratios: <math>\frac{16}{15}, \frac{10}{9}, \frac{6}{5}, \frac{5}{4}, \frac{27}{20}, \frac{45}{32}, \frac{64}{45}, \frac{40}{27}, \frac{8}{5}, \frac{5}{3}, \frac{9}{5}, \frac{15}{8}</math>, but when their factors of <math>2</math> and <math>3</math> are removed, they all reduce to <math>\frac{1}{5}</math> or <math>\frac{5}{1}</math>, and so they can all be notated using the same microtonal accidental, pointing either up or down, combined with different letters and sharps or flats. We say that <math>\frac{1}{5}</math> or <math>\frac{5}{1}</math> is the "2,3-reduced" form of these pitch ratios, and because <math>\frac{1}{5}</math> and <math>\frac{5}{1}</math> use the same accidental pointing either up or down, and because <math>\text{N2D3P9}</math> only operates on ratios whose numerator is larger than their denominator (superunison ratios), <math>\frac{5}{1}</math> can represent this entire "2,3-equivalent" class for the purpose of notation design.
# '''prime-limit''', which is also known as <math>\text{gpf}</math>, which stands for [https://mathworld.wolfram.com/GreatestPrimeFactor.html greatest prime factor]. <math>\text{prime-limit}(175) = 7</math>. Some authors leave <math>\text{prime-limit}(1)</math> undefined; we avoid the question because we define <math>\text{N2D3P9}(\frac{1}{1})</math> ≡ <math>\text{N2D3P9}(\frac{3}{1}) = 1</math>. This is because the ratios in the equivalence class represented by the 5-rough <math>\frac{1}{1}</math> actually have a prime limit of 3.
# The '''copfr''' function, which stands for "<u>C</u>ount <u>O</u>f <u>P</u>rime <u>F</u>actors with <u>R</u>epeats". It applies to any positive integer. For example <math>175</math> has the prime factorization <math>5 × 5 × 7</math>, which has 3 factors including the repeat of <math>5</math>, so <math>\text{copfr}(175) = 3</math>. <math>\text{copfr}(1) = 0</math>. <math>\text{copfr}</math> is also called the "[https://en.wikipedia.org/wiki/Prime_omega_function big omega]" function, <math>Ω</math>.
# The '''prime-limit''' function, which is also known as <math>\text{gpf}</math>, which stands for [https://mathworld.wolfram.com/GreatestPrimeFactor.html greatest prime factor]. <math>\text{prime-limit}(175) = 7</math>. Some authors leave <math>\text{prime-limit}(1)</math> undefined; we avoid the question because we define <math>\text{N2D3P9}(\frac{1}{1})</math> ≡ <math>\text{N2D3P9}(\frac{3}{1}) = 1</math>. This is because the ratios in the equivalence class represented by the 2,3-reduced <math>\frac{1}{1}</math> actually have a prime limit of 3.


So the formula for <math>\text{N2D3P9}</math>(<math>\frac{n}{d}</math><nowiki>) is:
Now we can give the formula for <math>\text{N2D3P9}</math>(<math>\frac{n}{d}</math><nowiki>) as:
$$
$$
\begin{cases}
\begin{cases}
\large{\text{N2D3P9}(\frac{n}{d})=\frac{n}{2^{\text{copfr}(n)}}×\frac{d}{3^{\text{copfr}(d)}}×\frac{\text{prime-limit}(nd)}{9}}, \\
\large{\text{N2D3P9}(\frac{n}{d})=\frac{n}{2^{\text{copfr}(n)}}×\frac{d}{3^{\text{copfr}(d)}}×\frac{\text{prime-limit}(nd)}{9}}, \\
\small{\text{    where }n\text{ and }d\text{ are 5-rough positive integers and }n>d.} \\
\small{\text{    where }n\text{ and }d\text{ are 2,3-reduced positive integers and }n>d.} \\
\large{\text{N2D3P9}(\frac{1}{1})=1} \\
\large{\text{N2D3P9}(\frac{1}{1})=1} \\
\end{cases}
\end{cases}
Line 46: Line 43:
where </nowiki><math>nd</math> is established in music theory as a ratio's "product complexity" or [[Benedetti height]].
where </nowiki><math>nd</math> is established in music theory as a ratio's "product complexity" or [[Benedetti height]].


The division by 9 does not affect the ranking, but it has the convenient effect that <math>\text{N2D3P9}</math> values are almost the same as the ranks they produce when applied to all 5-rough superunison ratios. Putting it another way, there are approximately <math>N</math> 5-rough pitch ratios with <math>\text{N2D3P9}≤N</math>. For example, <math>\text{N2D3P9}(\frac{77}{5}) = \frac{7}{2} × \frac{11}{2} × \frac{5}{3} × \frac{11}{9} ≈ 39</math>, suggesting there are approximately 38 other 5-rough pitch ratios more popular than <math>\frac{77}{5}</math>. There are actually about 4% fewer than that on average. In this case there are 36.
The division by 9 does not affect the ranking, but it has the convenient effect that <math>\text{N2D3P9}</math> values are almost the same as the ranks they produce when applied to all 2,3-reduced superunison ratios. Putting it another way, there are approximately <math>N</math> 2,3-reduced pitch ratios with <math>\text{N2D3P9}≤N</math>. For example, <math>\text{N2D3P9}(\frac{77}{5}) = \frac{7}{2} × \frac{11}{2} × \frac{5}{3} × \frac{11}{9} ≈ 39</math>, suggesting there are approximately 38 other 2,3-reduced pitch ratios more popular than <math>\frac{77}{5}</math>. There are actually about 4% fewer than that on average. In this case there are 36.


== Justification ==
== Justification ==


Why should we believe that <math>\text{N2D3P9}</math> accurately ranks the popularity of 5-rough pitch classes?
Why should we believe that <math>\text{N2D3P9}</math> accurately ranks the popularity of 2,3-equivalent pitch classes?


<math>\text{N2D3P9}</math> was developed (or discovered) rather late in the development of Sagittal notation. The Sagittal designers previously relied on actual ratio usage data from [http://www.huygens-fokker.org/microtonality/scales.html the Huygens-Fokker Foundation's scale archive], kindly provided by [[Manuel Op de Coul]].
<math>\text{N2D3P9}</math> was developed (or discovered) rather late in the development of Sagittal notation. The Sagittal designers previously relied on actual ratio usage data from [http://www.huygens-fokker.org/microtonality/scales.html the Huygens-Fokker Foundation's scale archive], kindly provided by [[Manuel Op de Coul]].


All scales in the archive were treated equally, as there was no information about their relative importance. Each occurrence of a pitch ratio in a scale was counted as one vote for that ratio. Then the ratios were grouped into 5-rough pitch classes and a single figure obtained for each 5-rough superunison ratio (representing the class). There were 29,403 votes, allocated to 820 5-rough ratios.
All scales in the archive were treated equally, as there was no information about their relative importance. Each occurrence of a pitch ratio in a scale was counted as one vote for that ratio. Then the ratios were grouped into 2,3-equivalent pitch classes and a single figure obtained for each 2,3-reduced superunison ratio (representing the class). There were 29,403 votes, allocated to 820 2,3-reduced ratios.


Like the frequency of use of letters in an alphabet, when sorted in order of decreasing popularity, the ratios obeyed an approximate [https://en.wikipedia.org/wiki/Zipf%27s_law Zipf's law] distribution, with the Nth most popular ratio having votes proportional to approximately <math>\frac{1}{N^{1.37}}</math>. This meant that about half the ratios had only one vote each, and three quarters of them had 3 votes or less. Such low numbers of votes meant that the data on the less popular ratios was vulnerable to "historical noise". In other words, the position of such a ratio in the list might not be a good predictor of its relative frequency of use in the future.
Like the frequency of use of letters in an alphabet, when sorted in order of decreasing popularity, the ratios obeyed an approximate [https://en.wikipedia.org/wiki/Zipf%27s_law Zipf's law] distribution, with the Nth most popular ratio having votes proportional to approximately <math>\frac{1}{N^{1.37}}</math>. This meant that about half the ratios had only one vote each, and three quarters of them had 3 votes or less. Such low numbers of votes meant that the data on the less popular ratios was vulnerable to "historical noise". In other words, the position of such a ratio in the list might not be a good predictor of its relative frequency of use in the future.
Line 75: Line 72:




However, their approach was not able to consider ''all'' possible psychoacoustic reasons for a ratio's popularity. For example, <math>\text{N2D3P9}</math> does not evaluate whether some member of a 5-rough equivalence class might be very close in pitch to some member of another equivalence class, such as <math>\frac{65}{64}</math> being very close to <math>\frac{1}{1}</math>.
However, their approach was not able to consider ''all'' possible psychoacoustic reasons for a ratio's popularity. For example, <math>\text{N2D3P9}</math> does not evaluate whether some member of a 2,3-equivalent class might be very close in pitch to some member of another such equivalence class, such as <math>\frac{65}{64}</math> being very close to <math>\frac{1}{1}</math>.


== Development & Discovery ==
== Development/Discovery ==


From May to August 2020, a [http://forum.sagittal.org/viewtopic.php?f=4&t=493 collaborative effort] to find such a function, was carried out by members of the [http://forum.sagittal.org/ Sagittal forum], led by Sagittal co-creator [[Dave Keenan]] and [[Douglas Blumeyer]]. Many functions besides <math>\text{N2D3P9}</math> were considered before selecting it as the best function for its purpose.
From May to August 2020, a [http://forum.sagittal.org/viewtopic.php?f=4&t=493 collaborative effort] to find such a function, was carried out by members of the [http://forum.sagittal.org/ Sagittal forum], led by Sagittal co-creator [[Dave Keenan]] and [[Douglas Blumeyer]]. Many functions besides <math>\text{N2D3P9}</math> were considered before selecting it as the best function for its purpose.
Line 85: Line 82:
Rather than attempt to fit functions to the exact counts of votes for each ratio, the functions were fit to the rank indices of each ratio; in other words, a function only needed to sort ratios the same as the actual data, and within each rank position it was unimportant how close its estimate of votes was. In technical parlance, the goal was to minimize the [https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient Spearman’s rank coefficient] between the estimated ranks and the actual ranks. For purposes of comparing competing functions, minimizing Spearman’s rank coefficient could be simplified to minimizing the sum of squared differences between the ranks. But because fitting to the simpler ratios which had more votes is more important, a Zipf's-law weighting was applied to the ranks by taking their reciprocals before calculating their squared differences. A [https://en.wikipedia.org/wiki/Ranking#Fractional_ranking_(%221_2.5_2.5_4%22_ranking) fractional ranking] strategy was used to ensure that stretches of the data with tied vote counts did not distort the measurement.
Rather than attempt to fit functions to the exact counts of votes for each ratio, the functions were fit to the rank indices of each ratio; in other words, a function only needed to sort ratios the same as the actual data, and within each rank position it was unimportant how close its estimate of votes was. In technical parlance, the goal was to minimize the [https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient Spearman’s rank coefficient] between the estimated ranks and the actual ranks. For purposes of comparing competing functions, minimizing Spearman’s rank coefficient could be simplified to minimizing the sum of squared differences between the ranks. But because fitting to the simpler ratios which had more votes is more important, a Zipf's-law weighting was applied to the ranks by taking their reciprocals before calculating their squared differences. A [https://en.wikipedia.org/wiki/Ranking#Fractional_ranking_(%221_2.5_2.5_4%22_ranking) fractional ranking] strategy was used to ensure that stretches of the data with tied vote counts did not distort the measurement.


The overall strategy, then, was to minimize this weighted rank correlation, while also minimizing the complexity of the function, to avoid overfitting. An earlier 5-rough-ratio notational popularity ranking function that had been used by the creators of Sagittal was <math>\text{sopfr}</math> ([https://mathworld.wolfram.com/SumofPrimeFactors.html sum of prime factors with repetition]), and as simple as this function is, it does a remarkably good job of estimating the rank of pitch ratios. For comparison, the weighted sum of squares that <math>\text{sopfr}</math> gives for the Scala stats is about 0.026, while the weighted sum of squares <math>\text{N2D3P9}</math> gives is about 0.010. Functions giving sums of squares as low as 0.008 were found, however, these functions were so complex that they probably were fitting to noise in the Scala stats instead of to the true nature of musical pitch. An informal “chunk” metric was devised to compare function complexity in terms of fit to the data, with considered functions ranging from one chunk (<math>\text{sopfr}</math>) to eight chunks; the winning function <math>\text{N2D3P9}</math> has five chunks.
The overall strategy, then, was to minimize this weighted rank correlation, while also minimizing the complexity of the function, to avoid overfitting. An earlier notational popularity ranking function for  2,3-reduced-ratios, that had been used by the creators of Sagittal was <math>\text{sopfr}</math> ([https://mathworld.wolfram.com/SumofPrimeFactors.html sum of prime factors with repetition]). It does a remarkably good job of estimating the rank of pitch ratios given how simple it is. However the weighted sum of squared errors that <math>\text{sopfr}</math> gives for the Scala stats is about 0.026, while <math>\text{N2D3P9}</math> reduces that to about 0.010. Functions giving sums of squares as low as 0.008 were found, however, these functions were so complex that they probably were fitting to noise in the Scala stats instead of to the true nature of musical pitch. An informal “chunk” metric was devised to compare function complexity in terms of ability to fit to the data, with considered functions ranging from one chunk (<math>\text{sopfr}</math>) to eight chunks; the winning function <math>\text{N2D3P9}</math> has five chunks.


Several techniques were used to find and decide on <math>\text{N2D3P9}</math> as the best 5-rough ratio notational popularity rank estimation function. Initial observations about shortcomings of <math>\text{sopfr}</math>, such as its failure to differentiate balanced ratios from their imbalanced equivalents — such as <math>\frac{11}{5}</math> versus <math>\frac{55}{1}</math> — or those with different prime limits such as <math>\frac{13}{5}</math> and <math>\frac{11}{7}</math>, despite those pairs of ratios exhibiting remarkably different actual ranks in the Scala stats, formed the basis of the investigation. Psychoacoustic plausibility of functions was used as a top-down guide for experimentation. [https://en.wikipedia.org/wiki/Mathematical_optimization Optimization] tools such as [https://www.microsoft.com/en-us/microsoft-365/blog/2009/09/21/new-and-improved-solver/ Excel's Evolutionary Solver] were used to navigate toward ideal values for each parameter. The approach that was finally successful was a brute-force approach implemented by Douglas Blumeyer, whereby nearly 2 billion functions combined out of constituent "submetrics" were checked automatically. In the end, one of the functions on the short-list generated from the brute-force checker was recognized as being re-writable in a much simpler form with parameter values rounded to whole numbers without doing much damage to its sum-of-squares, and thus <math>\text{N2D3P9}</math> was born.
Several techniques were used to find and decide on <math>\text{N2D3P9}</math> as the best 2,3-reduced ratio notational popularity rank estimation function. Initial observations about shortcomings of <math>\text{sopfr}</math>, such as its failure to differentiate balanced ratios from their imbalanced equivalents — such as <math>\frac{11}{5}</math> versus <math>\frac{55}{1}</math> — or those with different prime limits such as <math>\frac{13}{5}</math> and <math>\frac{11}{7}</math>, despite those pairs of ratios exhibiting remarkably different actual ranks in the Scala stats, formed the basis of the investigation. Psychoacoustic plausibility of functions was used as a top-down guide for experimentation. [https://en.wikipedia.org/wiki/Mathematical_optimization Optimization] tools such as [https://www.microsoft.com/en-us/microsoft-365/blog/2009/09/21/new-and-improved-solver/ Excel's Evolutionary Solver] were used to navigate toward ideal values for each parameter. The approach that was finally successful was a brute-force approach implemented by Douglas Blumeyer, whereby nearly 2 billion functions combined out of constituent "submetrics" were checked automatically. In the end, one of the functions on the short-list generated from the brute-force checker was recognized as being re-writable in a much simpler form with parameter values rounded to whole numbers without doing much damage to its sum-of-squares, and thus <math>\text{N2D3P9}</math> was born.


After deciding upon <math>\text{N2D3P9}</math>, the Sagittal forum members checked the ratios for the existing Sagittal symbols against it, to see how well they'd been served by the Scala archive stats and the earlier <math>\text{sopfr}</math> metric. Each symbol in Sagittal's JI notations has a default value, or primary comma, which allows it to exactly notate ratios in a 5-rough ratio equivalence class, and based on <math>\text{N2D3P9}</math>, it was found that only a couple of these commas should be changed (these were among the rarest-used symbols in Sagittal). This was as expected; <math>\text{N2D3P9}</math> was developed primarily in order to add new symbols to Sagittal, to enable it to exactly notate even rarer JI pitches than it already does.
After deciding upon <math>\text{N2D3P9}</math>, the Sagittal forum members checked the ratios for the existing Sagittal symbols against it, to see how well they'd been served by the Scala archive stats and the earlier <math>\text{sopfr}</math> metric. Each symbol in Sagittal's JI notations has a default value, or primary comma, which allows it to exactly notate ratios in a 2,3-equivalent class, and based on <math>\text{N2D3P9}</math>, it was found that only a couple of these commas should be changed (these were among the rarest-used symbols in Sagittal). This was as expected; <math>\text{N2D3P9}</math> was developed primarily in order to add new symbols to Sagittal, to enable it to exactly notate even rarer JI pitches than it already does.






== Table of Top 100 (5-Rough) Pitch Ratio Classes by N2D3P9 ==
== Table of Top 100 (2,3-equivalent) Pitch Ratio Classes by N2D3P9 ==
{| class="wikitable"
{| class="wikitable"
|+
|+
!5-rough pitch ratio class
!2,3-equivalent pitch ratio class
!N2D3P9
!N2D3P9
!N2D3P9 rank
!N2D3P9 rank